We have a column that comes from database as a value between 0 and 1. We use a formatter function for the column to make it a percentage (between 0 and 100) but when trying to filter for instance a 100, it does not show any results regardless that we have values for 1 in the data source. This is the function we use to format the column:
And this is the column definition:
These are the rows in the grid:
And this is the result when filtering the IFC % column with 100:
If we filter the IFC % column with 1 it works as expected:
Is there any way a grid column can be filtered (from the filter row) using the values from a formatter function instead of the source?
Thanks in advance.
Thank you for posting into our community!
I have been looking into your question and what I could say is that the behavior you are experiencing is because filtering, sorting, and paging are implemented in the igDataSource, while the formatting and templating logic is implemented in the igGrid. When using the formatter function to lookup a column value the underlying igDataSource used by the igGrid does not know about this and in order to filter the values correctly, there is a need for igDataSource to know the actual value shown in the grid.
Having this in mind, an approach I could suggest is using an unbound column which will hold the lookup value, while the actual “IFC %” column will be hidden. More detailed information along with samples and code snippets could be found in our Unbound Columns topic here.
Additionally, in order to demonstrate my suggestion, I have prepared a small sample using the abovementioned approach and it could be found here.
The result could be observed in the attachment below:
Please test this approach on your side and let me know if you need any further assistance regarding this matter.
Looking forward to your reply.
Sincerely, Riva Ivanova Associate Software Developer
Hello, Riva. This solution works perfectly but we need to be able to remote filter for the column so we ended up adding the column with the percentage value in the data source and that will do it. Your solution is great in case you do not need remote filter, sorting or group by features as explained in the documentation for issues and limitations on unbound columns.
I'll mark the answer as verified because it works but if somebody needs this with remote filtering, you may need to add the column in your data source. Thanks,
Thank you for following up!
I am glad that you found a solution and managed to achieve your requirement.
Additionally, another possible approach when using remote filtering is implementing the filtering logic on the server side and I believe that you will find our Handling Remote Features Manually topic here quite helpful as it provides detailed information along with code snippets demonstrating how features such as paging, filtering, sorting/groupBy and summaries could be handled remotely.
Attached could be found a small sample using the approach demonstrated in the Handling Remote Filtering section. For simplicity and demonstration purposes, I have included filtering logic only for the “Discount %” column, i.e., additional logic should be included for the other columns.
Thank you for using Infragistics components.