CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Color cell text

by etwoss » 28 Feb 2014 09:04

Hi

In my grid i have a date colums, if the date is in the past i have to show it in red.

How can i do this?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 28 Feb 2014 11:51

Hello

Using the information in this post:

http://www.cgdevtools.com/cgforum/viewtopic.php?f=34&t=438&p=2025&hilit=cell+color#p2025

you can set

Col.OnCellAttr.Script:= 'function (rowId,val,rawObject,cm,rdata){ return '' color=''red'"; }';

if it's constant. If it depends on values from your data set use OnLoadComplete and the method described in the post above.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 03 Mar 2014 14:19

H
Using this code in the grdMainJQGridOptionsLoadComplete method

for i:= 0 to RowIds.Count-1 do
begin
Cls:= SO();
Cls.S['color']:= 'red';
grdMain.JQGridOptions.SetCell(RowIds[i],'BESCHRIJVINGKORT','',Cls,Props);
end;


Count = 7
I have a grouped grid
Only the first BESCHRIJVINGKORT is colored red, why?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 03 Mar 2014 15:10

Hi

Only the first BESCHRIJVINGKORT is colored red, why?


Because you're calling

grdMain.JQGridOptions.SetCell(RowIds[i],'BESCHRIJVINGKORT','',Cls,Props);

?

If you want to set to all cells in each row, you can do the following:

procedure TIWForm12.GridLoadComplete(Sender: TObject; AParams: TStringList);
var
RowIds: TStrings;
i: Integer;
Data: ISuperObject;
Cls: ISuperObject;
begin
RowIds:= TStringList.Create;
try
FGrid1.GetRowIds(RowIds);
Data:= SO();
Cls:= SO();
Cls.S['color']:= 'red';
for i:= 0 to RowIds.Count-1 do
begin
FGrid1.JQGridOptions.SetRowData(RowIds[i],Data,Cls);
end;
finally
RowIds.Free;
end;
end;
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 03 Mar 2014 16:16

Hi

That way all cells are red, what i ment was that out of the seven records , only the first one was red, the other six not
this while grdMain.JQGridOptions.SetCell(RowIds[i],'VERLOOPDATUM','',Cls,Props) references RowIds[i], so i thought it would do it for every VERLOOPDATUM cell in the grid

Other question:

while looping through the rows , i need to have some value from the dataset behind the row, how can i point the dataset to that row?

Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 03 Mar 2014 16:29

Hi

what i ment was that out of the seven records , only the first one was red, the other six not


What are you RowIds[i] values? each of the 7?

while looping through the rows , i need to have some value from the dataset behind the row, how can i point the dataset to that row?


I'm not following you, can you please reformulate the question? tia.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 03 Mar 2014 19:44

Hi

>>What are you RowIds[i] values? each of the 7?

Yes from 1 to 7

>>while looping through the rows , i need to have some value from the dataset behind the row, how can i point the dataset to that row

I need to do a test of a date field of the dataset behind the grid. Only if this date is passed the text of the cell must become red
So i need to let the dataset point to the correct record to get to the datefield.



Eric
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 03 Mar 2014 20:49

Hi

After making a remote session, we show you how you can do it using the above code and also Grid.CellValues. This property contains the last values loaded to a grid page
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by etwoss » 05 Mar 2014 11:30

Still not solved, trying to contact you this evening for help on skype
etwoss
 
Posts: 1205
Joined: 06 Feb 2014 08:58

by Jorge Sousa » 05 Mar 2014 21:43

After we made a remote session, we find out that

In the KeyFields, the FieldNames contained spaces between the commas: 'Field1, Field2, ...' when they should set as 'Field1,Field2,...'. But we're going to filter that.

Also, the Date Values in property Grid.CellValues have the format yyyy-mm-dd, so to convert to date we must use

uses
IWCGJQGridCustomProvider;

var
D: TDate;

D:= StrToDate(Grid.CellValues[c,r],CGXmlFormatSettings);

We found a bug in the method LocateSelectedRowId when there are date fields in the RowID definition Grid.JQGridProviderDataSet.KeyFields. Fixed for next release.

We also found a bug in the method Grid.JQGridOptions.GroupingToogle, to be fixed asap.

Thank you very much for your time, these remote sessions can be very productive for both
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

Next

Return to JQGrid

Who is online

Users browsing this forum: No registered users and 3 guests

Contact Us.