-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GreaterThan and LessThan Filter method to Blazorise DataGrid component? #4941
Comments
It's not a bad idea, but the problem could be that our filter methods are generic enum that is shared for all column types. Not sure how we could extend on that. @David-Moreira any idea?
Yes, you can do that already. Use the /// <summary>
/// Represents the function for the <see cref="DataGridColumn{TItem}"/> custom filtering.
/// </summary>
/// <param name="itemValue">An item value in a column cell for which the filter is executed.</param>
/// <param name="searchValue">Searching value.</param>
/// <returns>True it the value has passed the filter operation.</returns>
public delegate bool DataGridColumnCustomFilter( object itemValue, object searchValue ); It can be used as(might need adjusting casts): CustomFilter="@((value, search) => (int)value >= (int)search)" |
Thank you for your response. I am using Menu Mode filtering. Some of my columns in the grid are numeric and some are just text. For the numeric columns, I want to give them Equal, Not Equal, Less Than and Greater Than filter options. For the text columns, I want to give them the default filters available in Data Grid. However, using custom filters, is there a way to customize the Menu (Menu Mode Filters) based on the type of column, so that columns will get filters based on the type of data (numeric vs. text). |
@stsrki is on the right path with the current DataGrid capabilities. I will get back to you with a more concrete example once I get the time. But it should be possible to customize it to your liking, it just takes a bit more work. A combination of the feature You modify the template with your own filtering capabilities, it can be your own defined enum, and then on the custom filter you filter based on your own filtering capabilities. However I'm not sure how easy it will be to implement it such that it can be generic enough for your use case. I.E having numeric filters applied to every numeric column, etc... EDIT: With steps for a numeric filter for example https://blazorise.com/docs/extensions/datagrid/features/filtering @stsrki I do think it's interesting if we explore in providing better & expected contextual filtering mechanism for the numeric, date, etc columns... @JLfarhan if you end up figuring out a solution before I take a more concrete look at this, please let us know your findings. :) |
@David-Moreira Thanks for your detailed response and direction. I will explore it further on my end too and share what I find. Due to lack of time (with other responsibilities), I might not be able to explore a generic solution. I might just build a custom template for a couple of numeric columns using |
The new filter menu is great. Adding ability to filter by numeric or DateTime values would make this even better. |
Hello, Here's a very quick dirty example, I just focused on making it work, I didn't bother too much with details, data types, etc... just an example, you'll have to adapt the code, to make it more reusable, more elegant, etc... But I think this might be an acceptable starting point:
|
@David-Moreira wanna write the blog post describing this solution? |
Well sure, it should only be a temporary fix but I guess it will help people looking for this. I'll improve the example and write the post later. |
Thanks |
Thank you, I appreciate your help. I couldn't get this to work as I am using server-side filtering/sorting and |
The code I posted is a generalized example as a temporary fix. You will have to adapt it and probably fix any bugs if any. The example given is for static data, not readdata, althought it should work similarly, prioritized getting the search value from a new |
Example updated: The following example should be ready to run, and actually have working filters, where we can see Greater and Lesser than in action for a numeric column and also working together with a regular column filter. So it's a nice place to start. As for
|
Is your feature request related to a problem? Please describe.
I'm using Blazorise DataGrid component. The currently supported filtering methods include the following:
However, I have a need to filter a column with numeric values using Greater Than and Less Than operators (filter methods). Is there a way to add new Filter methods to Blazorise DataGrid component? For example, add GreaterThan and LessThan filter methods for DataGridNumericColumn?
Describe the solution you'd like
I would like DataGrid Filter methods to include GreaterThan and LessThan methods. At a minimum, I'm expecting that there is an example or documentation of extending the filter component to add the additional filter methods.
Additional context
I am using Blazorise.DataGrid version 1.3.0.
Edit: I am loading data from External source, so my filtering will be on the server side: https://blazorise.com/docs/extensions/datagrid/binding-data/large-data
The text was updated successfully, but these errors were encountered: