We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to sort grouping in datagrid

I added a simple datagrid in the boiler plate Visual Studio blazor project and when I drag a column to enable grouping, it will group properly but I can't change the way it sorts (ascending and descending). The arrow will show up next to the label but clicking it does nothing. Below is my datagrid code:


<SfGrid AllowGrouping="true" AllowPaging="true" DataSource="@Orders" Height="100%" Width="100%" >

    <GridGroupSettings Columns="@test"></GridGroupSettings>

    <GridColumns>

        <GridColumn Field=@nameof(Order.ReleaseName) HeaderText="Release Name" Type="ColumnType.String"></GridColumn>

        <GridColumn Field=@nameof(Order.ArtistName) HeaderText="Artist Name" Type="ColumnType.String"></GridColumn>

        <GridColumn Field=@nameof(Order.DateSubmitted) Format="d" HeaderText="Date Submitted" Type="ColumnType.Date"></GridColumn>

    </GridColumns>

</SfGrid>

@test is referencing the DateSubmitted property.


2 Replies

AN Anthony February 5, 2023 03:47 PM UTC

I figured out the issue. I did not enable sorting on the grid.


<SfGrid AllowGrouping="true" AllowPaging="true" AllowSorting="true" DataSource="@Orders" Height="100%" Width="100%">

    <GridGroupSettings Columns="@test" ></GridGroupSettings>

    <GridSortSettings>

        <GridSortColumns>

            <GridSortColumn Field="DateSubmitted" Direction="SortDirection.Descending"></GridSortColumn>

        </GridSortColumns>

    </GridSortSettings>

    <GridColumns>

        <GridColumn Field=@nameof(Order.ReleaseName) HeaderText="Release Name" Type="ColumnType.String"></GridColumn>

        <GridColumn Field=@nameof(Order.ArtistName) HeaderText="Artist Name" Type="ColumnType.String"></GridColumn>

        <GridColumn Field=@nameof(Order.DateSubmitted) Format="d" HeaderText="Date Submitted" Type="ColumnType.Date"></GridColumn>

    </GridColumns>

</SfGrid>



SP Sarveswaran Palani Syncfusion Team February 8, 2023 03:19 AM UTC

Hi Anthony, 

We are glad that you could find the solution by enabling sorting in your grid. Please get back to us for further assistance. 

We are marking this ticket as solved. 

Regards,

Sarvesh 


Loader.
Up arrow icon