Disable UI virtualization in Radgridview

3 Answers 300 Views
GridView
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Om Pushkara deep asked on 22 Jun 2021, 07:43 AM

Hi ,

i have a radgridview with lengthy columns (actually 3 columns with the 3rd as minwidth 4000 which is a custom chart column) . So this comes up with scrolling effect if the monitor size is small . It seems that due to virtualization , the data in some rows (the 3rd column) disappears randomly on scroll. Any way to avoid that?

 

Guess disabling virtualization should do but any other idea is welcome

3 Answers, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jun 2021, 01:12 PM
Hello, Om Pushkara deep,  


The internal mechanism in RadGridView is built in such a way that it uses virtualization which means that the visual cell elements are created only for the currently visible cells and they are being reused during operations like scrolling. It is not possible to disable the virtualization but you can manage properly the custom cells and the data they display.

It seems that you use a custom cell that hosts a chart view in it. I suppose that your custom implementation is based on the solution suggested in the previous thread that you have on this topic: 
https://www.telerik.com/forums/have-a-grid-of-3-columns-with-2-columns-as-text-and-3rd-as-a-chart-in-telerik-2015-winforms

You can override the SetContentCore method of the custom cell and manipulate the chart's DataPoints collection and add/remove the desired points according to the cell's Value you store. Thus, for each chart cell you may have different values. It is up to you how exactly you will store the values per each row. It is just necessary to extract this value in the SetContentCore method and populate the chart with DataPoints

I have extended the previous example for your convenience and you can see the achieved result in the gif file. When scrolling the columns, the chart data remains as expected. Please give the sample project a try and see how it works on your end.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 24 Jun 2021, 02:34 PM

That works fine . But in other 2 columns i wanted it the cell to be red based on a condition.
I tried cellformatting event to make a column's cell red based on condition but the color keeps juggling when i scroll back and forth . Is there a best way to do it ?
1
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Jun 2021, 04:53 AM

Hello, Om Pushkara deep,  

Indeed, the CellFormatting event is the appropriate way to apply red color to the grid cells.  In order to prevent applying the formatting to other columns' cell elements (because of the cell reuse), all customization should be reset for the rest of the cell elements. 

I have prepared a sample code snippet for your reference: 

        private void RadGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (e.CellElement.ColumnInfo.Name == "Column2")
            {
                if (e.CellElement.Value != null && int.Parse(e.CellElement.Value.ToString()) == 7)
                {
                    e.CellElement.ForeColor = Color.Red;
                }
                else
                {
                    e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
                }
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
            }
        }

I believe that you will find the provided sample useful for achieving your requirement.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Jun 2021, 06:00 AM

Thanks . It really was very useful . One final doubt in this question , i wanted the vertical axis to be visible only in the first row alone and not in other rows. Should i keep a counter to implement this , if i do that the visibility goes on and off when i scroll . Any elegant way to achieve it?
Dess | Tech Support Engineer, Principal
Telerik team
commented on 25 Jun 2021, 01:03 PM

@Om Pushkara deep, In the custom ChartCell and its SetContentCore method (LoadBarChart method in particular) you can customize the axis and set its IsVisible property to true/false considering the RowIndex. thus, you can control for which rows the axis to be shown.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Jun 2021, 01:18 PM

In LoadBarChart() how can i find the row index it is rendered in. i guess only the 3rd column value to filter in SetContentCore() method is got as input . Is there any other event i need to handle in chartcolumn class?
1
Nadya | Tech Support Engineer
Telerik team
answered on 29 Jun 2021, 01:24 PM

Hello,

As Dess suggested in the SetContentCore method in your custom ChartCell you can specify the visibility of the axis by considering the RowIndex. Please refer to the following code snippet:

protected override void SetContentCore(object value)
{
    base.SetContentCore(value);
    LoadBarChart();

    if (this.RowIndex == 0)
    {
        verticalAxis.IsVisible = true;
    }
    else
    {
        verticalAxis.IsVisible = false;
    }
}

I hope this helps. Let me know if you have any other questions. 

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
commented on 29 Jun 2021, 01:26 PM

Thanks that helped .I would highly recommend telerik to people especially for its customer support too !!
Tags
GridView
Asked by
Om Pushkara deep
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Nadya | Tech Support Engineer
Telerik team
Share this question
or