We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom row style selector refresh rows based on values.

Hi,

I have a custom RowStyleSelector applied to SfDataGrid, its functionality is to change background color of certain rows based on some cell values. It works well with initial values. However when user changes those value doesn't automatically change row color. How can I trigger the row style selector update in those scenarios?

Thanks,
Vasanth

5 Replies

JG Jai Ganesh S Syncfusion Team September 22, 2015 11:27 AM UTC

Hi Vasanth,


Thank you for using Syncfusion Products.


We have analyzed your query. When changing the value at runtime the StyleSelector is not called and the style is not applied based on the changed value. However you can achieve this requirement by calling the UpdateDataRow method and also by calling the InvalidateMeasureInfo() for visual container in the CurrentCellEndEdit event.


Code Example [C#]:


void datagrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs args)

  {

        var rowindex = args.RowColumnIndex.RowIndex;

        this.datagrid.UpdateDataRow(rowindex);

  }


We have also prepared a sample based on this and you can download the sample from the below location,


Sample: http://www.syncfusion.com/downloads/support/directtrac/143149/ze/SfGridDemo-1646472712


Please let us know if you need further assistance.


Thank you,

Jai Ganesh S



VA Vasanth September 22, 2015 02:29 PM UTC

Perfect, thank you!!


JG Jai Ganesh S Syncfusion Team September 23, 2015 04:21 AM UTC

Hi Vasanth,


Thank you for the update.


Please let us know if you need further assistance on this.


Thank you,

Jai Ganesh S



GR Gregory March 18, 2016 03:10 PM UTC

Hello,

How to do the same with WPF ?

Thank you.


JS Jayapradha S Syncfusion Team March 21, 2016 11:13 AM UTC

Hi Vasanth,

You can trigger the style selector when you changed the cell value by using UpdateDataRow method in WPF  like in WinRT.
Please find the sample for WPF platform from the following location,

Sample Link: http://www.syncfusion.com/downloads/support/forum/120502/ze/RowStyleSelector_WPF906788637

Please refer the below KB document to change the cell value at runtime,
KB Link: https://syncfusion.com/kb/5992/how-to-change-the-gridcell-style-at-runtime

Regards,
Jayapradha


Loader.
Live Chat Icon For mobile
Up arrow icon