Page 1 of 2
Color cell text
Posted:
28 Feb 2014 09:04
by etwoss
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
Re: Color cell text
Posted:
28 Feb 2014 11:51
by Jorge Sousa
Hello
Using the information in this post:
http://www.cgdevtools.com/cgforum/viewtopic.php?f=34&t=438&p=2025&hilit=cell+color#p2025you 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.
Re: Color cell text
Posted:
03 Mar 2014 14:19
by etwoss
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
Re: Color cell text
Posted:
03 Mar 2014 15:10
by Jorge Sousa
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;
Re: Color cell text
Posted:
03 Mar 2014 16:16
by etwoss
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
Re: Color cell text
Posted:
03 Mar 2014 16:29
by Jorge Sousa
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.
Re: Color cell text
Posted:
03 Mar 2014 19:44
by etwoss
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
Re: Color cell text
Posted:
03 Mar 2014 20:49
by Jorge Sousa
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
Re: Color cell text
Posted:
05 Mar 2014 11:30
by etwoss
Still not solved, trying to contact you this evening for help on skype
Re: Color cell text
Posted:
05 Mar 2014 21:43
by Jorge Sousa
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