Column sorting in RadGridView

1 Answer 44 Views
GridView
Lukasz
Top achievements
Rank 1
Lukasz asked on 06 Jul 2021, 06:39 AM | edited on 06 Jul 2021, 07:04 AM

I'm using RadGridView quite a lot. One of the major functionality is column sorting.

This is radGridView definition. RadGridStyle contains set properties as follows:

    <Style x:Key="RadGridStyle" 
           TargetType="{x:Type telerik:RadGridView}">
        <Setter Property="ItemsSource" 
                Value="{Binding Elements}" />
        <Setter Property="AutoGenerateColumns" 
                Value="False" />
        <Setter Property="EnableRowVirtualization" 
                Value="True" />
        <Setter Property="EnableColumnVirtualization" 
                Value="True" />
        <Setter Property="FrozenColumnCount" 
                Value="5" />
        <Setter Property="ClipboardCopyMode"
                Value="All"/>
        <Setter Property="SelectedItem" 
                Value="{Binding SelectedElement}"/>
        <Setter Property="SelectionUnit" 
                Value="FullRow"/>
        <Setter Property="SelectionMode" 
                Value="Extended"/>
        <Setter Property="MinColumnWidth" 
                Value="75"/>
        <Setter Property="CanUserSortColumns"
                Value="True"/>
        <Setter Property="IsReadOnly"
                Value="True"/>
        <Setter Property="RowHeight"
                Value="20"/>
        <Setter Property="DataLoadMode"
                Value="Synchronous"/>
        <Setter Property="ValidatesOnDataErrors"
                Value="None"/>
        <Setter Property="GroupRenderMode"
                Value="Flat"/>
    </Style>
<telerik:RadGridView Style="{StaticResource RadGridStyle}">
            <telerik:RadGridView.Columns>
<!--int--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Index, Mode=OneTime}" Header="{x:Static localization:Resources.Identifier}"/> <!--string--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name, Mode=OneTime}" Header="{x:Static localization:Resources.Signature}"/> <!--string--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Group, Mode=OneTime}" Header="{x:Static localization:Resources.Group}"/> <!--string--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Code, Mode=OneTime}" Header="{x:Static localization:Resources.Code}"/> <!--string--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Description, Mode=OneTime}" Header="{x:Static localization:Resources.Description}"/> <!--Voltage struct, it implements IComparable/IEquatable--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Data.NominalVoltage, Mode=OneTime}"> <telerik:GridViewDataColumn.Header> <controls:TextBlockForDataGridColumnHeader Text="Un (kV)" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> <!--Voltage struct--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Data.SwitchgearRatedVoltage, Mode=OneTime}"> <telerik:GridViewDataColumn.Header> <controls:TextBlockForDataGridColumnHeader Text="Ur (kV)" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> <!--string, it doesn't work even for this simple type property--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Data.SwitchgearType, Mode=OneTime}" Header="{x:Static localization:Resources.SwitchgearType}"/> <!--Current struct, it implements IComparable, IEquatable--> <telerik:GridViewDataColumn DataMemberBinding="{Binding Data.RatedCurrent, Mode=OneTime}"> <telerik:GridViewDataColumn.Header> <controls:TextBlockForDataGridColumnHeader Text="Ir (A)" /> </telerik:GridViewDataColumn.Header> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>

RadGridView can use column sorting only for columns no 1-5. Other columns have no ability to sort. There are no sort indicators on column header for each column. When I'm trying to add DataType or SortMemberPath for each column, inidicator appears, but clicking on indicator has no effect. Filter popup contains just only 0 or [null] value

 

This is definition of model, that I'm binding to radGridView. The collection ItemsSource is of type <IEquipment>.


public class Equipment : IEquipment
    {
        public int Index { get; set; }

        public string Name { get; set; }

        public string Code { get; set; }

        public string Description { get; set; }

        public string Group { get; set; }

        public IData Data { get; }
    }

public class Busbar : IData, 
    {
        public Voltage NominalVoltage { get; set; }
        public Voltage SwitchgearRatedVoltage { get; set; }
        public string SwitchgearType { get; set; }
        public Current RatedCurrent { get; set; }
    }

 

I'm afraid that there are some problems with nested objects binding, because whem I'm trying to bind flatten definition of these two types (Equipment and Busbar), there are no problems.

 

Thank you for your help!

1 Answer, 1 is accepted

Sort by
1
Martin Ivanov
Telerik team
answered on 08 Jul 2021, 09:41 AM

Hello Lukasz,

I've tested this but I couldn't reproduce the issue. Can you try the attached project and let me know if I am missing anything?

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Lukasz
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or