This is a migrated thread and some comments may be shown as answers.

Formatting RadVirtualGrid with DataProvider

2 Answers 155 Views
VirtualGrid
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 12 Dec 2017, 08:23 PM

Sirs,

I'm using RadVirtualGrid with a Custom DataProvider and I would like to format its columns where some columns would fit their width to their content, others to their cells' content, some columns would have their cells aligned to left, others to right, and so on.

I mean I want to apply a different style to each column in my RadVirtualGrid, however I don't know how to handle these styles.

Thanks in advance,

2 Answers, 1 is accepted

Sort by
0
Luis
Top achievements
Rank 1
answered on 12 Dec 2017, 08:29 PM
 <Style TargetType="telerik:RadVirtualGrid">
  <Setter Property="HorizontalAlignment" Value="Stretch" />
  <Setter Property="VerticalAlignment" Value="Stretch" />
  <Setter Property="CanUserEdit" Value="False" />
  <Setter Property="CellTextAlignment" Value="Right" />
  <!--<Setter Property="ColumnHeaderBackground" Value="Red"></Setter>-->
 </Style>
0
Vladimir Stoyanov
Telerik team
answered on 15 Dec 2017, 03:19 PM
Hello Luis,

In order to fit column width to the content of the cell you can use the FitColumnWidthToContent method of the RadVirtualGrid. The FitColumnWidthToContent method receives the index of the column, you want to fit to its content. In order to enable this functionality you need to set the MeasureTextOnRender property of the RadVirtualGrid to "True". You can read some more about that in the Getting Started article in our documentation.

As for conditionally setting the TextAlignment, it is currently not supported. This is why I have logged in a feature request for you in our feedback portal where you can vote for it and track its progress.

I hope you find this helpful. Let me know if I can be of any further assistance.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
VirtualGrid
Asked by
Luis
Top achievements
Rank 1
Answers by
Luis
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or