Formatting RadVirtualGrid with DataProvider

3 posts, 0 answers
  1. Luis
    Luis avatar
    12 posts
    Member since:
    Sep 2017

    Posted 12 Dec 2017 Link to this post

    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. Luis
    Luis avatar
    12 posts
    Member since:
    Sep 2017

    Posted 12 Dec 2017 Link to this post

     <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>
  3. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    79 posts

    Posted 15 Dec 2017 Link to this post

    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.
Back to Top