Hello
I have to need to set the background to each row different way also based on some property value changes, I need to change the background of the row as well runtime. I have attached the screenshot, I want a similar row and cell background also those brush values can be changed runtime.
Can someone guide me on how can I achieve this without affecting the performance much?
Thanks in advance.
Parthiv
4 Answers, 1 is accepted
Hi Parthiv,
Thank you for the provided image.
You can consider using the CellDecorationsNeeded event of the RadVirtualGrid. In the event handler, you can get the cell and modify it per your needs. Keep in mind that when a cell is edited, this event will be fired for all cells in the viewport. You can read more about this event in the Conditional Styling help article in our documentation.
Regards,
Dinko
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Hello Dinko,
Thanks a lot for the response. I went through OverlayBrushesNeeded and it seems to me that, we need to provide a fixed set of brushes into that event only.
But the scenario I have is, the user can select the color using ColorPicker and I want to color the cell using that selected color. So I do not have fixed/predefined brushes.
Can you please guide how can I achieve this or how can I explicitly raise the OverlayBrushesNeeded event so that can pass new brushes into the control?
Thanks in advance.
Parthiv

Hi parthiv,
The OverlayBrushesNeeded event will be called when the control is loaded. You can't raise it afterward. The only option here to change the background of a cell runtime is to use the CellDecorationsNeeded event. This event will be called runtime when the control is scrolled or when you edit a cell. I can't suggest you an option to trigger the OverlayBrushesNeeded even and add more colors runtime.
The need to create this RadVirtualGrid control was to introduce a much faster data grid component. We couldn't do this with RadGridView because many implementation details would require rewriting the huge portions of logic to improve different performance scenarios. Also, RadGridView is very feature-rich and tries to convert as many scenarios out of the box as possible which puts some limitations on the performance. The VirtualGrid resolves the performance aspect for the cost of fewer features and less style customization availability. If UI customization is required in your application you can consider using RadGridView control instead.
Regards,
Dinko
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Hello Dinko,
Thanks for the response, and I understand your suggestion.
Though I have a query, you mentioned " The OverlayBrushesNeeded event will be called when the control is loaded. You can raise it afterward." .. Can you tell me how to raise the OverlayBrushesNeeded event afterward or explicitly?
Thanks,
Parthiv
Generally speaking, is not recommend to do that when you have a large number of rows. It could lead to a performance hit if the user is reloading the control very often. Still, you can try it in your application and tested to see if such behavior is observed. To reload the control, you can reset its template.
private void RadButton_Click(object sender, RoutedEventArgs e){
var template = this.vg.Template;
this.vg.Template = null;
this.vg.Template = template;
}