Hi
I am using the formatter for several grid columns to apply formatting on numbers to required decimal places. The problem I am seeing is that if you have multiple values which format to same value they still show independently in the list. So for example if I format 0.0001 and 0.0002 to 2dp then they both become 0.00 but I would see 0.00 appear twice in the list. Each item then only selects it's underlying item
Is there a way to ensure that the excel style filter takes into account the formatter? In it's current state I can't see how using formatters is possible with filtering since the duplicate options referring to different entries make it impossible to use.
Is there any way to get it working so that if things format to same value that they appear once and select all related values?
Thanks
Hello Katy Faulkner,
Thank you for contacting us! Based on the requirement, I see two options:
Option 1: Format the data before passing it to the Grid.
Option 2: Use a unique value strategy - the list items (values) can be provided manually and loaded on demand. This is mostly relevant to the Remote data operations, although in your case it would be handful as well. This uniqueColumnValuesStrategy input is accepting column, filteringExpressionTree and done callback that would be called with the newly added column values when they are passed.
Following the above will populate the list with the desired values BUT that wouldn't be enough. If you select the "0.00" item from the list, nothing will be filtered, as the relying data items would still be 0.0001 and 0.0002. This is why another custom implementation is needed, this time for the Filtering operands - you should create custom filtering operands for conditions like Equals, Not Eq, Greater than and etc. - example.
Grid's Filtering feature is very powerful and rich, and you can achieve almost everything with it, although there are cases when these type of changes are more suitable for the data change implementation, before passing it to the Gird, this is why my recommendation is to follow Option 1.
Option 1: If I pre-format the data then I would have strings instead of numbers. Then I need to have custom logic for allowing sorting and filtering on string numbers properly.
Option 2: I can't see in the custom filter operands that it knows anything about the formatter so I am not sure how I could apply the same formatting there. It seems like I would need to have a custom filter operand per formatter?
I am leaning towards needing to pre-enrich all the data but to me this is really disappointing that the grid does not fully support these features as other grids have that. Are there any plans to support filtering on formatted vaules or introduce some sort of valueGetter that allows the underlying data to be modified and taken into account for searching/filtering/sorting features
Also it doesn't seem to be using my filtering operands for the set filter only for the custom filters (when you click text/data/number to apply more complex filter). How do I make it use the filter operands on the set filter also?
Additionally I just realized another issue which is that I am using the summaries feature currently. If I pre-format all my numbers to 2dp then I will not get accurate results for my summaries since I want to calculate those on the raw data and then format them. So I can't really see how option 1 could work well for me.
All in all, the desired scenario is very specific and to be honest hardly achievable - Formatting underlying numeric data to string, limiting the filtering list to show it uniquely and later on filter it by the underlying numeric data (in order to show it in the result list).
Feel free to add a feature request for Filtering on the formatted values, it would be a good request worth discussing it.