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
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/.
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 ?
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, 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.
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/.