Link to home
Start Free TrialLog in
Avatar of Mateen
Mateen

asked on

For every datawindow retrieved, is it possible to show negative values of all numeric columns in red colour.

For every datawindow retrieved, is it possible to show negative values of all numeric columns in red colour.
Avatar of Sys_Prog
Sys_Prog
Flag of India image

Hi Mateen,
Write an expression at runtime

Cheers!
Mateen,
If u have to make it generic,
Then let all your datawindows be inherited from your customized datawindow
Let the customized datawindow (in one of its initialization events) run a loop over all the columns and for all numeric columns, write an expression such that if value < 0, the color = RED

Avatar of sajuks
sajuks

A simpler way would be to directly paste this in the format of the field
#,###;-[RED]#,###
But in that case, all your data window objects would have to be modified

In the solution I suggested, there would just be a couple of lines addition to the ancestor object and all is done

Amit
This is what we normally use
 #,###;[RED](#,###);0
Am just giving another solution. I nev'r said yours is wrong.
Avatar of Mateen

ASKER

Hi Sysprog:
Let the customized datawindow (in one of its initialization events) run a loop over all the columns and for all numeric columns

my ancestor datawindow is dw_1
now,
Exact name of the event.
Ho to loop fo find numeric column names.
When numeric column found, how to pass modify statement to set red colour.

What I mean is that I have got the idea but am unable to script it.
Hi mateen just a hint

creat your own event and call it after you have retrived the data using the retrieve command

script for that event

long ls_count,i
string ls_number,ls_colname
ls_count = dw_1.Object.DataWindow.Column.Count

for i= 1 to ls_count
//set the current column
dw_1.setcolumn(i)

//get the column name
ls_colname=dw_1.GetColumnName()
ls_number=string(dw_1.Object.Data[1,i])
if isnumber(ls_number) then
   dw_1.Modify( ls_colname+".Color='0~tIf("+ls_colname+"< 0,255,65280)'")
End if
Next


i think this should work

if you have any error message just let us know
Just a side-note, If there are too many  records then during retireval you might've a performance
problem. So od take that also into consideration when writing your code
SOLUTION
Avatar of Bhatti
Bhatti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As per the question, for every datawindow, the color of numeric data < 0 should be red

So, my solution was probably the most generic one

Amit