Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.18k stars 517 forks source link

Datagrid Sorted Group #5516

Open zandiarash opened 1 month ago

zandiarash commented 1 month ago

Hi community I used a Datagrid in a project, I have grouped my table by a column (Days) image

I want to ask how can I make my days orderByDescending ?

This is how I fill my binded collection

  var res = Faults0DtoAll.OrderByDescending(x => x.FromDateTime).ToList();
  Faults0DtoToShow = new ObservableCollection<Fault0Dto>(res);

And this is my Grid

<DataGrid TItem="Fault0Dto"
          Data="@Faults0DtoToShow"
          Sortable="true"
          PageSize="@totalItems"
          SortMode="DataGridSortMode.Single"
          Striped="true"
          Hoverable="true"
          Groupable
          Responsive
>
    <DataGridColumns>
        <DataGridColumn TItem="Fault0Dto" Field="@nameof(Fault0Dto.ErrorCode)" Caption="کد خطا" />
        <DataGridColumn TItem="Fault0Dto" Field="@nameof(Fault0Dto.ErrorDesc)" Caption="توضیح خطا" />
        <DataGridColumn TItem="Fault0Dto" Field="@nameof(Fault0Dto.FromDayFa)" Caption="روز" SortField="@nameof(Fault0Dto.FromDayEn)" SortDirection="SortDirection.Descending" Displayable="false" Groupable Grouping />
        ...
    </DataGridColumns>
    <EmptyTemplate>
        <p>هنوز داده ای موجود نیست</p>
    </EmptyTemplate>
</DataGrid>