<EjsGrid @ref="GridInstance" DataSource="@Orders" AllowSorting="true" AllowMultiSorting="true" AllowPaging="true">
<GridEvents OnActionComplete="OnActionComplete" TValue="Order"></GridEvents>
...
</EjsGrid>
@code{
EjsGrid<Order> GridInstance;
...
public async void OnActionComplete(ActionEventArgs<Order> args)
{
if(args.RequestType.ToString() == "Sorting" && args.ColumnName == "CustomerID")
{
await Task.Delay(200);
//Now sorting the “CustomerID” column will automatically sort the “Orderdate” column also.
GridInstance.SortColumn("OrderDate", SortDirection.Ascending, true);
}
}
...
}
|
<style>
.e-grid .e-hidemultisort .e-sortnumber {
display:none; /*Hide the circled sorting order number*/
}
.e-grid .e-hidemultisort .e-sortfilterdiv.e-icons {
display:none; /*Hide the circled sorting arrow icon*/
}
.e-grid .e-hidefirstsort .e-sortnumber {
display:none; /*Hide the circled sorting order number for the first sorted column*/
}
</style>
<EjsGrid @ref="GridInstance" DataSource="@Orders" AllowSorting="true" AllowMultiSorting="true" AllowPaging="true">
<GridEvents OnActionComplete="OnActionComplete" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) CustomAttributes="@(new { @class="e-hidemultisort"})" ...></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) CustomAttributes="@(new { @class="e-hidefirstsort"})" ...></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) CustomAttributes="@(new { @class="e-hidemultisort"})" ...></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</EjsGrid>
@code{
EjsGrid<Order> GridInstance;
...
public async void OnActionComplete(ActionEventArgs<Order> args) /*OnActionComplete will be triggered for each sort action*/
{
if(args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Sorting && args.ColumnName == "CustomerID")
{
await Task.Delay(200);
GridInstance.SortColumn("OrderDate", SortDirection.Ascending, true); /*Sort OrderDate column*/
}
else if(args.RequestType == Syncfusion.EJ2.Blazor.Grids.Action.Sorting && args.ColumnName == "OrderDate")
{
await Task.Delay(200);
GridInstance.SortColumn("OrderID", SortDirection.Ascending, true); /*Sort OrderID column*/
}
}
...
}
|