Rad GridView Cell Formatting

2 posts, 0 answers
  1. Krunal
    Krunal avatar
    1 posts
    Member since:
    Nov 2014

    Posted 25 Mar 2015 Link to this post

    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,


  2. Dess
    Dess avatar
    2107 posts

    Posted 30 Mar 2015 Link to this post

    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.

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

Back to Top