Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Sorting of single column based on multiple secondary sort in xamgrid.
posted

Hi, We are using xamgrid and initially doing sorting on one column on loading of xamgrid. Now as duplication of items occurs in that column, we need to sort on basis of other secondary columns.

For sample take this code below:

<ig:XamGrid AutoGenerateColumns="False" ItemsSource="{Binding Items}" >
<ig:XamGrid.SortingSettings>
<ig:SortingSettings ></ig:SortingSettings>
</ig:XamGrid.SortingSettings>
<ig:XamGrid.Columns>
<ig:TextColumn Key="Side" MinimumWidth="20" Width="50">
<ig:TextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Side" ToolTip="Trade Side"></TextBlock>
</DataTemplate>
</ig:TextColumn.HeaderTemplate>
</ig:TextColumn>
<ig:TextColumn Key="CreatedOn" MinimumWidth="30" Width="68" FormatString="{}{0:HH:mm:ss}" AllowToolTips="Always" IsSorted="Descending">

<ig:TextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Created On" ToolTip="Date and time trade was created"/>
</DataTemplate>
</ig:TextColumn.HeaderTemplate>
<ig:TextColumn.ToolTipContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding CreatedOn, StringFormat={}{0:dd/MM/yyyy HH:mm:ss:fff}}" />
</DataTemplate>
</ig:TextColumn.ToolTipContentTemplate>
</ig:TextColumn>
</ig:XamGrid.Columns>
</ig:XamGrid>

Now here if in CreatedOn column if date is same for some rows, sorting should happen based on Side column.

How should I achieve that in xamgrid. I know there are some possibilities in xamDataGrid by using FieldlayoutSorting. But could you please tell in xamgrid case.
Thanks. 

  • 2180
    Offline posted

    Hello Mukesh,

    You can enable the multi column sorting feature in the xamGrid by setting the AllowMultipleColumnSorting property to True.

    <ig:XamGrid.SortingSettings>

       <ig:SortingSettings AllowMultipleColumnSorting="True" />

    </ig:XamGrid.SortingSettings>

    I’ve attached a sample application for a reference.

    Let me know if you have any questions with this matter.

    xamGridSorting.zip