The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I am trying to get the grid to change the cell background color depending on some internal state information. I have the logic in the QueryCellInfo event which sets e.Style.Background to the brush I want but it appears to have no effect unless I call InvalidateVisuals(true) elsewhere in the code. If my understanding is correct InvalidateVisuals causes the entire grid to be repainted. In my case it's very undesirable as this a high-frequency update type of scenario. Please explain the right way to implement this. Thank you,
JJJeraldes J Syncfusion Team August 4, 2010 12:30 PM UTC
Hi Alex,
Thanks for using Syncfusion products.
When you call InvalidateVisual(true) it only clears the volatile styles, there may be some instances where the internal store would have cached the data.
You need to call Model.InvalidateCell(GridRangeInfo range); to mark the cell range as dirty, and then calling Model.InvalidateVisual(true) will force the grid to query for those particular cells again.
you can set the range the cell to be invalidated using the GridRangeInfo.
I need some clearification here please. When I call InvalidateCell the document says it invalidates cached value for the cell and resets visuals associated with the cell.
1. What do you mean by visuals? 2. When you call the InvalidateVisual with "true" the doc says "forces complete new layout". The doc does not make the difference between InvalidateVisual() and InvalidateVisual(true) clear, please clearify. 3. If the InvalidateVisual(true) "forces complete new layout" it seems like a very inefficient way to go about this. Should we use InvalidateCellBackground?
Thank you.
JJJeraldes J Syncfusion Team August 6, 2010 01:21 PM UTC
Hi Alex,
1. Visual- we mean that the objects that are currently visible on the screen, including the cells, content of the cell and the styles of the cells that are visible on the screen.
2. InvalidateVisual() which will refresh the hole grid that are visible.
InvalidateVisual(true) – will update the cells that are dirt. Which means the cells that are to be updated alone will be updated. For example when you are using QueryCellInfo() to particular cells. Those updated cells are called as dirt cells, these dirt cells will only be invalidated using this InvalidateVisual(true).
3. If your requirement is only to change the background of the cells alone you can use the InvalidateCellBackground(). InvalidateVisual will invalidates the whole objects that are visual, as mentioned in 1.