{"id":32,"date":"2010-06-17T20:20:00","date_gmt":"2010-06-18T01:20:00","guid":{"rendered":"http:\/\/anvil-of-time.com\/2010\/06\/17\/powerbuilder-change-background-of-modified-columns-in-datawindow\/"},"modified":"2021-03-08T19:34:54","modified_gmt":"2021-03-09T00:34:54","slug":"powerbuilder-change-background-of-modified-columns-in-datawindow","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-change-background-of-modified-columns-in-datawindow\/","title":{"rendered":"PowerBuilder &#8211; Change Background of Modified Columns in Datawindow"},"content":{"rendered":"<p>Okay so you have a datawindow with a bunch of rows which can be edited (a grid datawindow is a good choice).\u00a0 So when the user pulls up the data set and proceeds to change values in a variety of columns and a variety of rows you want to indicate to him that the specific row\/column has been changed by altering the background color.<\/p>\n<p>I have a solution of sorts which, once you get it going, will work.\u00a0 It involves:<br \/>\n1) adding a column on the datawindow object<br \/>\n2) populating that column in the itemchanged event<br \/>\n3) putting an expression on the background color property of each visible column in the datawindow object you want the color to change when edited<\/p>\n<p>1) I added a string column called &#8216;change&#8217; (not a computed col) to my datawindow object.<\/p>\n<p>2) in the Itemchanged event on the Datawindow<\/p>\n<pre name=\"code\" class=\"VB\">   \/\/ build a list of the column numbers which have been edited.\u00a0\n   \/\/ You can enhance this to account for errors, etc.\n   string ls_desc, ls_value, ls_d, ls_prev\n  \u00a0integer li_rc\n   ls_desc =\u00a0 dwo.name + &#039;.ID&#039;\n  \u00a0ls_d = describe(ls_desc)\n  \u00a0ls_prev = getitemstring(row,&#039;change&#039;)\n   IF IsNull(ls_prev) THEN ls_prev = &#039;&#039;\n   ls_value = ls_prev + &#039;[&#039; + ls_d + &#039;]&#039; \/\/ append new value\n  \u00a0li_rc =\u00a0\u00a0\u00a0 this.setitem( row, &#039;change&#039;, ls_value)\n<\/pre>\n<p>3) in the background color of a column called &#8216;box3&#8217; put the following expression<\/p>\n<pre name=\"code\" class=\"VB\">IF (pos(change[0], &#039;[&#039; + describe(&#039;box3.ID&#039;) + &#039;]&#039;) &gt; 0, RGB(255,255,0),RGB(255,255,255))<\/pre>\n<p>As an alternative, you can make step three dynamic in an open\/postopen type event:<\/p>\n<pre name=\"code\" class=\"VB\">dw_1.retrieve( )\ndw_1.setredraw( False)\n\/\/ get list of columns in the order they are displayed which may not be the same as their column number order\nll_max = Integer(dw_1.Object.DataWindow.Column.Count)  \/\/ determine number of columns\nFOR ll_i = 1 TO ll_max STEP 1\n   \/\/ only need the visible columns\n   IF dw_1.describe(&quot;#&quot; + String(ll_i) + &quot;.Visible&quot;) = &#039;1&#039; THEN\n     \/\/ first set the mode to opaque\n     ls_modstring = dw_1.describe( &quot;#&quot; + string(ll_i) +  &quot;.Name&quot;) +  &quot;.Background.Mode=&#039;0&#039;&quot;\n     ls_msg = dw_1.Modify(ls_modstring)\n     \/\/ set the color of the cells\n     ls_modstring = dw_1.describe( &quot;#&quot; + string(ll_i) +  &quot;.Name&quot;) +  &quot;.Background.Color =  ~&quot;536870912~t IF (pos(change[0],~&#039;[~&#039; + describe(~&#039;&quot; + &amp;\n       \u00a0dw_1.describe( &quot;#&quot; + string(ll_i) +  &quot;.Name&quot;) + &quot;.ID~&#039;) + ~&#039;]~&#039;) &gt; 0, RGB(255,255,0),RGB(255,0,255))~&quot;&quot;\n\n     ls_msg = dw_1.Modify(ls_modstring)\n   END IF\n\nNEXT\n\ndw_1.setRedraw(true)\n<\/pre>\n<p><!--more--><br \/>\nSample view:<\/p>\n<p><a href=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/06\/multicolordw-1.bmp\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1737\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/06\/multicolordw-1.bmp\" alt=\"\" width=\"398\" height=\"155\" \/><\/a><\/p>\n<p><a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/06\/multicolordw.bmp\"><img class=\"alignnone size-full wp-image-78\" title=\"multicolordw\" src=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/06\/multicolordw.bmp\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay so you have a datawindow with a bunch of rows which can be edited (a grid datawindow is a good choice).\u00a0 So when the user pulls up the data set and proceeds to change values in a variety of columns and a variety of rows you want to indicate to him that the specific&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[21,12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/32"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=32"}],"version-history":[{"count":13,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/32\/revisions"}],"predecessor-version":[{"id":1738,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/32\/revisions\/1738"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}