This is a migrated thread and some comments may be shown as answers.

RadGridView CellStyleSelector Value==null

2 Answers 137 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 10 Nov 2014, 12:13 PM
Hi
I have a RadGridView bound to a collection and I am adding the columns and their bindings manually in code-behind.
One of the columns has a CellStyleSelector set which is checking the cell value for a negative value (and assigning a style to change the foreground color to red).
This is all working fine when entering values into the grid (positive values are black and negative are red).
However when the grid is initially loaded with data and the columns added, the negative numbers are black.
This is happening because when the style selector is called the first time (after the data has loaded and columns added) the GridViewCell Value property is null.
If I were to then click in a cell to make it go into edit mode and press enter, the style selector is called again - this time with a valid value - and the correct style is applied.
As a test, if I refresh the bindings (notify all properties changed) on a timer after say 1 second, then the style selector is called again with correct values etc.
So my question is: why is GridViewCell Value property null the first time and how can I overcome this?

Thanks,
Mike.

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 11 Nov 2014, 02:25 PM
Hello Mike,

Generally, you should work with the data items and the values of their properties rather than the Value of the cell. Could you verify whether you cannot modify your logic so that it counts on the data and not on visual elements ?


Regards,
Maya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mike
Top achievements
Rank 1
answered on 12 Nov 2014, 12:37 PM
Hi Maya
Thanks for your response.
I have since modified my code to use a DataTrigger (binding to the underlying data) and it is all working now.
Thanks,
Mike.
Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mike
Top achievements
Rank 1
Share this question
or