Refresh QueryRowStyle

Hey,

I am using QueryRowStyle to color some rows based on a property. Everything works fine.
However, I am calling some function after that which performs a calculation and changes some of the data. The colors should change accordingly.
Is there a way to trigger an event that will "refresh" the grid and therefore call the QueryRowStyle function again.

Thanks in advance!

7 Replies

KK Karthikraja Kalaimani Syncfusion Team May 4, 2020 11:05 AM UTC

Hi Karim,

Your requirement can be achieved by calling the Refresh() method of SfDataGrid after your calculations done. Please refer the below code snippet.

Code snippet:

 
SfDataGrid.Refresh() 
Regards,
Karthik Raja




KE Karim el Safadi May 7, 2020 08:53 AM UTC

Thanks so much, great support! Worked like a charm!


KK Karthikraja Kalaimani Syncfusion Team May 8, 2020 05:42 AM UTC

Hi Karim,

Thank you for the update. We glad to know that your requirement has been achieved. Please let us know if you have any further queries on this. We are happy to help you.

Regards,
Karthik Raja 



RF RAFAEL FELIPE SACOMANI May 8, 2020 01:27 PM UTC

hi, can i refresh a single row by index to force queryrowstyle?


KK Karthikraja Kalaimani Syncfusion Team May 11, 2020 12:41 PM UTC

Hi Rafael,

Currently, we are validating your requirement. we will validate and update your further details on or before 13th May 2020. We appreciate your patience until then.

Regards,
Karthik Raja 



KK Karthikraja Kalaimani Syncfusion Team May 13, 2020 01:51 PM UTC

Hi Rafel,

Still we need some more to find a suitable workaround for your requirement. So, we will update further details on or before 15th May 2020. We appreciate your patience until then.

Regards,
Karthik Raja




KK Karthikraja Kalaimani Syncfusion Team May 15, 2020 12:42 PM UTC

Hi Rafael,

Your requirement can be achieved by calling the UpdateRowStyles method of DataRowBase class. Here we have called UpdateRowStyles method only when the RowData  is equal to the first data of the viewModel collection.

Code snippet :

 
for (int i = 0; i < this.textGrid.GetRowGenerator().Items.Count; i++) 
            { 
                if (this.textGrid.GetRowGenerator().Items[i].RowData != null) 
                { 
                    if (this.textGrid.GetRowGenerator().Items[i].RowData.Equals(viewModel.OrdersInfo[i-1])) 
                    { 
                        var row = (DataRowBase)this.textGrid.GetRowGenerator().Items[i]; 
                        this.textGrid.GetRowGenerator().Items[i].GetType().GetRuntimeMethods().FirstOrDefault(x => x.Name.Equals("UpdateRowStyles")).Invoke(row,null); 
                         
                        break; 
                    } 
                } 
            } 

Note :  We can only get visible rows from GetRowGenerator() method.

Regards,
Karthik Raja 


Loader.
Up arrow icon