Quicklist to users for grouping and sorting

4 posts, 1 answers
  1. Inger Marie
    Inger Marie avatar
    86 posts
    Member since:
    Nov 2010

    Posted 06 Feb Link to this post

    I have a radgridview with a bunch of columns. Each column has defined how to group and sort.

    For instance:

    • The data: MeetingDate is a of a custom type, which has a Tostring()-override that returns the datetime as date only (and implements IComparable<T>, IEquatable<T>
    • GroupHeaderTemplate: Writes the date if there is one. Writes "None" otherwise
    <telerik:GridViewDataColumn x:Name="_meetingDateColumn" IsReadOnly="True"
                                    Header="Meeting date"
                                    DataMemberBinding="{Binding MeetingDate.TheDateTime, UpdateSourceTrigger=PropertyChanged}"
                                    GroupHeaderTemplate="{StaticResource GridDateColumnGroupHeaderTemplate}"
                                   Width="SizeToCells"
                                    GroupMemberPath="MeetingDate">
                                    <telerik:GridViewDataColumn.HeaderCellStyle>
                                        <Style TargetType="telerik:GridViewHeaderCell">
                                            <Setter Property="ToolTipService.ToolTip" Value="Date when meeting is taking place"/>
                                            <Setter Property="ToolTipService.ShowDuration" Value="{x:Static Member=system:Int32.MaxValue}" />
                                        </Style>
                                    </telerik:GridViewDataColumn.HeaderCellStyle>
      
                                    <telerik:GridViewDataColumn.CellTemplate>
                                        <DataTemplate >
                                            <TextBlock VerticalAlignment="Top"
                                                    Text="{Binding MeetingDate.TheDateTime, StringFormat={}{0:g}}"
                                                    ToolTipService.Placement="Center" />
                                        </DataTemplate>
                                    </telerik:GridViewDataColumn.CellTemplate>
                                </telerik:GridViewDataColumn>


    I have around 20 columns, some are dates like the one above. One is industry, which groups by the category (http://ec.europa.eu/competition/mergers/cases/index/nace_all.html) but the column sorts by the entire industry name. Others are completely different - most have special handling of grouping and sorting.

    The user is supposed to play around with grouping and sorting to find interesting stuff. However  - in addition - I would like to provide a few preset options, which the user should be able to choose in a drop down and have the grid re-arrange itself accordingly.

    I would hate to implement all 20 grouping and sorting again - is there any way I can reuse the defination of sort and group from the columns in the gridview - and apply them to the radgridview group panel programatically ?

     

    Thanks,

     

  2. Answer
    Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 09 Feb Link to this post

    Hello Inger Marie,

    If I am understanding your enquiry correctly, you should be able to benefit from the programmatic sorting and grouping that RadGridView supports. The logic of these operations might be executed based on the selection of a RadComboBox, for example.

    Would such an approach suit your needs or I am missing something?

    Regards,
    Stefan X1
    Telerik by Progress
    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.
  3. Inger Marie
    Inger Marie avatar
    86 posts
    Member since:
    Nov 2010

    Posted 09 Feb in reply to Stefan Link to this post

    Yes - this is also what I have found out. I created a custom class which contains a list affected columns together with their wanted settings (for instance IsGrouped (boolean).

    This seems to work - I have even added a filter for determining if any of the resulting groups should be expanded or not.

    When the user selects an instance of this custom class in a combobox, the codebehind will run through the list of columns and do stuff based on the properties. Like this:

    if (IsGrouped)
    {
          ColumnSortDescriptor sortDescriptor = new ColumnSortDescriptor
           {
                Column = filter.Column,
                SortDirection = filter.ColumnSortDirection.Value
           };
            _theGridView.SortDescriptors.Add(sortDescriptor);
    }

     

    When ever the user selects "No filter" in the combobox - or prior to selecting another setting, I will call :

    _theGridView.CollapseAllGroups();
     _theGridView.FilterDescriptors.SuspendNotifications();
    foreach (GridViewColumn column in _theGridView.Columns)
        column.ClearFilters();
    _theGridView.FilterDescriptors.ResumeNotifications();
     
    _theGridView.GroupDescriptors.Clear();
    _theGridView.SortDescriptors.Clear();

     

    This seem to work within the boundaries of my specific needs.

  4. Stefan
    Admin
    Stefan avatar
    774 posts

    Posted 10 Feb Link to this post

    Hello Inger Marie,

     I am happy that you've found a solution that meets your requirements.

    In case you need any other assistance with our components, do not hesitate to contact us again.

    All the best,
    Stefan X1
    Telerik by Progress
    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