Open joost00719 opened 2 years ago
You can do that with SortField
parameter.
Example:
<DataGridColumn Field="Name" SortField="SomethingElse" />
But you cannot use a field of an object inside your class.
In my example I need to access Children.Count, this is not accessable. Besides that, it can be null and has an internal setter.
I guess you can implement that same logic in the custom field getter.
public int SomethingElse => Children?.Count == 0;
If that doesn't work for you, we could consider adding something similar to what you propose.
That was my initial thought to use. However, the problem is that the list of objects I am trying to render, cannot be modified as it is from an internal nuget packages for our Domain Models.
I think adding a sort method to the component itself would be the best solution.
Can you make a View model inherited from your domain model?
I'll try that. Thanks for the suggestion. Maybe keep this open to see if there's interest or not?
Sure, it's not a bad idea to have.
Is your feature request related to a problem? Please describe. I am trying to order rows based on a value which is not defined in a field, but can be calculated with a method.
Describe the solution you'd like A clear and concise description of what you want to happen. Include any alternative solutions you've considered. I would like to see a method which takes in a TItem, and needs to return an int. This implementation should be very close to the System.IComparable interface With this solution you are able to render objects you cannot modify (e.g. because it is a nuget package, or in a separate DLL)
Additional context
Add any other context or screenshots about the feature request here. Implementing would look something like this or
which should be applied on the Blazorise.DataGrid.DataGridColumn