1. Glenn Barber
  2. PowerBuilder
  3. Friday, 4 September 2020 23:22 PM UTC

I need to be able to set an attribute into a cell (row+column) in a grid datawindow which can be used to highlight or otherwise change the appearance of that cell by means of a datawindow expressions - and which can be read out by a program exporting the data to an excel report so that it can similarly test this value and supply the appropriate display formatting in Excel.

One of the only attributes I know of which can be set and programmatically tested on a cell by cell basis is what can be set using the powerscript SetItemStatus function.

This allows me to set the status by row and/or by column and later use the getitemstatus the value set.

The problem is that i only know of the IsRowModified() function supported in dw expressions and it seems to be missing the very much needed IsColumnModified() equivalent which could be easily used to highlight required entries or fields that were entered.  

Ive seen various getarounds - like calling global functions from within the dw expression which in turn call the getitemstatus - something I would probably use as a last resort.

So the question is - is there a simple solution for testing the columns modified status from within a datawindow column's datawindow expression for background and/or text color - or alternately is there another attribute of a specific cell which can be programmatically be set to accomplish the same and be easily retrieved?

 

 

 

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Sunday, 6 September 2020 23:06 PM UTC
  2. PowerBuilder
  3. # 1

Hi Glenn,

I know it's not considered as best practice and you don't like the idea of a global function too much, but I do think it is the simplest solution.

We use lots of global functions in most of our datawindows for colors and labels, etc. and haven't had any problem at all in years. (if that might be reassuring).

If you're worried about the functions constantly doing the call to the global function with GetItemStatus() when scrolling or refreshing / redrawing the datawindow, then you could set a retrieval argument (which you can use in computed columns) or a computed dummy column in the select which you set to 0 or 1.

Your expression would then be something like 

if ( dummy = 0, "currentstatus"*, gf_global_function(...))

*"currentstatus" would be whichever value you use to store the status in.

regards

 

Comment
  1. Miguel Leeuwe
  2. Tuesday, 8 September 2020 20:24 PM UTC
Yes there's "@col" which holds the column name if I'm not mistaken.



See https://community.appeon.com/index.php/qna/q-a/find-out-column-name-in-an-expression

The "#" is not necessary.
  1. Helpful
  1. Glenn Barber
  2. Wednesday, 9 September 2020 06:00 AM UTC
HI Miguel



I did revert to working on the global function which does a getitemstatus - and the returned value then tested in the background color expression of a cell - however for some reason this works for some datawindows and not others - even with the same code. While I am sure the correct datawindow is tested and I see it running the function in the debugger, for some datawindows the global function does not return datamodifed even when a local script does. Partly this might have to do with the reference to the datawindow from the global function - but not sure. Do you have any suggestions that might sort out how to best get this functional?
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 9 September 2020 08:14 AM UTC
I'm not sure, would have to see some code:

- how do you get a reference to the dw in a global function in an attribute of a column?

Have you seen my suggestion on "https://community.appeon.com/index.php/qna/q-a/how-do-i-pass-the-row-and-col-to-a-global-function-from-a-dw-expression?limitstart=0#reply-23076";

I think I found a solution and attache a sample app.

regards
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Saturday, 5 September 2020 19:38 PM UTC
  2. PowerBuilder
  3. # 2

Since there is no IsColumnModified() DW expression function, you'll have to decide on an alternate strategy, implementation, whatever you want to call it.

One way I might approach the problem is for the result set that drives the DW to have two instances of every column you wish to check, but have only one instance be shown as a column in the grid and the other be available only in the DW buffers. For example, "lastname" and "lastname_orig".

Then you can code DW expressions for background color, font color, etc. by comparing the values in the two column DWObjects.

If that doesn't work for you, another possible alternative would be to include your own "item status" column in the result set for every editable grid data column, then provide code to manage the behind-the-scenes "item status" value in each visible value's own "item status column" via the ItemChanged event, RetrieveEnd event, etc. That would also give you the ability to code expressions based on each "real" value's item status with the most flexibility. PITA to some extent, but it might be workable.

Comment
  1. Glenn Barber
  2. Saturday, 5 September 2020 20:46 PM UTC
Thanks John - I have done this before (and may end up with it) - generally creating a sql computed column in the SQL Source for each column - super tedious when there are already hundreds of columns. Ive thought about perhaps creating an Array column - but then would need to have some way to access the specific element in the array from the dw expressions. I was hoping there has got to be a way to access the modified attribute as they use this in the update process.
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Saturday, 5 September 2020 13:25 PM UTC
  2. PowerBuilder
  3. # 3

" highlight required entries "

for fields that do not have data but should, just check for value and set color appropriately with expression. You can also set it up to be required on a condition of another field.

you can also set a format for null and/or empty - so you can display text such as **MISSING** if the field is null

Comment
  1. Glenn Barber
  2. Saturday, 5 September 2020 17:02 PM UTC
That works for missing - but doesnt handle identifying the changed records - really need a way to flag cells in a way that can be used in expressions and read back under powerscript...
  1. Helpful
  1. mike S
  2. Saturday, 5 September 2020 20:31 PM UTC
yup, no way to do that short of adding your own columns that you do setitems on when another column changed. I agree that there should be a columnmodified or cellmodified expression added.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.