How to remove gird's column sorting through code when reload the gird?

Hello Radzen Team,

I am using Radzen 3.3.1 and RadzenDataGrid, very first the data is loaded in the grid through the LoadData event, and if I apply to sort on any column and then intensionally I wanna reload my grid, I just used gird.Reset() to remove filters and then grid.Reload(). It calls the LoadData event and gets the data successfully but the sorting arrow is still there on the grid and args.OrderBy also contains the same column's order value.
Could you please help me with how to reset the sorting before reloading the grid?

Thanks,
Shloke Ghenghat.

Just like filters, Is this possible to reset the sorting?

Thanks!

You can set SortOrder property of the DataGrid columns to null.

Hello @enchev,

Thank you so much for your quick response.
Can you please suggest how to find SortOrder property through code on the .cs file?

I tried on the razor page but it doesn't reflect any change on the grid.

Thanks!

Hello @enchev,

I got the property as grid.ColumnsCollection[0].SortOrder and before call grid.Reload() I set this to null, [0] as I was only tried to sort the first column, but this is not working.

Hello @enchev,

I also tried as below but it didn't work for me. Could you please review and suggest? Thanks

public async Task ReloadGrid()
{
        GridSorting(false);
        grid.Reset();
        await grid.Reload();
 }
private void GridSorting(bool isSort)
    {
        foreach(var col in grid.ColumnsCollection)
        {
            col.Sortable = isSort;
            if(!isSort)
                col.SortOrder = null;
        }
    }
protected async Task LoadData(LoadDataArgs args)
  {
        Console.Writeline(args.OrderBy); //always got value if filter is applied on the column
        ....//api calling
        ....
  }

Hi, I also would like to add to the problems with " DataGrid Sort API" which is visible on the demo page... The initially set SortOrder property of the "First Name" column doesn't apply sorting on the data.

We will do our best to provide fix for this with our next update.