Virtual Grid : How to set the background to each row different.

4 Answers 26 Views
VirtualGrid
parthiv
Top achievements
Rank 1
Iron
parthiv asked on 10 May 2021, 09:30 AM

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

Sort by
0
Dinko
Telerik team
answered on 12 May 2021, 11:41 AM

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.

0
parthiv
Top achievements
Rank 1
Iron
answered on 12 May 2021, 12:33 PM

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

 

 

0
Dinko
Telerik team
answered on 14 May 2021, 07:56 AM | edited on 14 May 2021, 08:24 AM

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.

0
parthiv
Top achievements
Rank 1
Iron
answered on 14 May 2021, 08:05 AM

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

 

Dinko
Telerik team
commented on 14 May 2021, 08:26 AM

I made a mistake in the text. Accept my apologies. I mean to say that you can't raise it afterward.
parthiv
Top achievements
Rank 1
Iron
commented on 14 May 2021, 08:27 AM | edited

So only way is, to reload the control again ?
Dinko
Telerik team
commented on 16 May 2021, 07:44 AM

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;
}
Tags
VirtualGrid
Asked by
parthiv
Top achievements
Rank 1
Iron
Answers by
Dinko
Telerik team
parthiv
Top achievements
Rank 1
Iron
Share this question
or