Mewriick / Blazor.FlexGrid

GridView component for Blazor
MIT License
199 stars 35 forks source link

How do I add sorting? #50

Closed redowl3 closed 5 years ago

redowl3 commented 5 years ago

My project is client side hosted in ASP.NET Core

hikarin522 commented 5 years ago

https://github.com/Mewriick/Blazor.FlexGrid/blob/2cc9977a57d34245ea434ebf1a08aa7f7a2bae59/demo/Blazor.FlexGrid.Demo.Server/Controllers/SampleDataController.cs#L62

https://github.com/StefH/System.Linq.Dynamic.Core/wiki/Dynamic-Expressions#iqueryable-extension-methods

Mewriick commented 5 years ago

@redowl3

It depends on which DataAdapter you are using if you using CollectionDataAdapter you just need for your columns which you want to allow sorting use configuration method

    builder.Property(/* your property expression */)
            .IsSortable();

If you are using LazyDataAdapter you also must provide into controller action method query parameters SortExpression and SortDescending. You can use for query paramters Dto object FlexGridQueryDto which FlexGrid provide. After that you must sort items. Example Controller link is in commet above.

redowl3 commented 5 years ago

Thanks both for the responses. @Mewriick is there any way to enable sorting for all columns without specifying each column individually?

Mewriick commented 5 years ago

@redowl3
Unfortunately now there is no possibility to enabled sorting for all columns. I will add this feature.

Mewriick commented 5 years ago

@redowl3 I add builder method that allow enable sorting for all columns on EntityTypeBuilder<TEntity> builder