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

Rad GridView Cell Formatting

1 Answer 574 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Krunal
Top achievements
Rank 1
Krunal asked on 25 Mar 2015, 01:56 PM
Hello Team,

I am using rad gridview in one of my ongoing application. I have 4 radgrids in my form. I have one primary grid which will be filled in my forms OnLoad event. On my forms load event, columns and data will be loaded dynamically for the  Primary gridView. Based on key field value my application will fetch records for the remaining three grids.This will happen on Primary radgridview's cell click event. 

In the primary gridview i have a column for which i want to keep fore color based on certain condition. This column shows the status of a particular items expiry date. if the item has already expired then this column text value is "expired" and the forecolor should be red. if item is getting expired within 30 then the fore color should be orange and if item expiry date is more than 30 days then fore color is green.

I am Formatting the cell in CellFormatting event. In this event i am checking whether the CellElement is GridViewDataColumn , if yes then will check the value of the cellelement ie text property. Conditionally i will assign the forecolor. Formatting for the status column is absolutely fine but at the same time it also changes the fore color for other columns data. whenever i move the mouse over these columns  or scroll the gridview to see other rows the forecolor keeps changing randomly  e.g initial it will be red then on mouse hove or on radgridview row scrolling top - bottom and vice -versa fore color is some times red,orange,green,black for these columns.

Please help in avoiding the other columns getting forecolor. Other columns except status column should have normal black forecolor.

Thanks & Regards,

Krunal.









1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Mar 2015, 07:34 AM
Hello Krunal,

Thank you for writing.

Due to the UI virtualization in RadGridView, cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. In order to prevent applying the formatting to other columns' cell elements (because of the cell reuse) all customization should be reset for the rest of the cell elements.  Please refer to our Formatting Cells help article. I have prepared a sample project for your convenience.

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Dess
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
Krunal
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or