Hi, when i try to filter a TMSFMXGrid i get an Error: "argument out of range" I just use the built in Filtersystem. No programmatical settings. Version: 2.8.0. Delphi: XE6 BS: IOS Maybe the reason is that i use more than one fixed row? BR Juergen Bucher
I went ahead and created a new project file, dropped down the TMSFMXGrid and enabled the DropDown Filtersystem (which I was referring to).
Then I filled it with some example values and tried to use it, which got me to the error. Under Windows it works as intended, for iOS I'm getting the "argument out of range" exception.
Hi Jurgen ... I found a solution to this problem that seems to fix the issue on both windows and mac. From my experience, I get the "argument out of range" error when I apply a filter to the grid, and then attempt to sort the data by clicking the top-most fixed cell of a given column to perform the sort.
The fix to this is to simply unhide all the filtered columns just before you sort, then re-apply the filter again after the sort is completed.
To do this, you need to create the following 2 event procedures for your TMSFMXGrid:
procedure TMainForm.GridCanSortColumn(Sender: TObject; ACol: Integer; var Allow: Boolean); begin //this prevents the "out of argument" or "out of range" errors when sorting with filters if (Sender as TTMSFMXGrid).Filter.Count > 0 then (Sender as TTMSFMXGrid).UnHideRowsAll; end;
procedure TMainForm.GridColumnSorted(Sender: TObject; ACol: Integer; Direction: TSortDirection); begin //this prevents the "out of argument" or "out of range" errors when sorting with filters if (Sender as TTMSFMXGrid).Filter.Count > 0 then (Sender as TTMSFMXGrid).ApplyFilter; end;
Also ... another problem I found, was the filters are not working correctly when filtering numbers in a grid on a iOS Mac. The fix for this problem was to comment out some code in the FMX.TMSGridDataUtil.pas file .. you need to comment out the {$IFDEF MACOS} section located near line 402. If took a lot of searching, but the problem is the function StripThousandSep is not defined for a mac .. so the "Val" expressions in the "Matches" functions won't work on a Mac. Therefore, you need to comment out those lines so the "StripThousandSep" will work, and therefore, the filters will function correctly on a mac.
hopefully, the team over at TMS Software will see this message and fix that problem in the next version of the TMS Pack for Firemonkey. The current version I am using is version v2.8.0.1
I am able to filter columns now - but I have another Issue when using the MultiColumn property of the Drop-Down-Filter:
Steps to reproduce:
- Filter column A
- Filter is correct
- Filter column B
- Filter is still correct
- Reset filter with TTMSFMXGRID.RemoveFilter
- All entries are correctly shown again with no filter present
- Filter column A (again)
- Filter is not correct anymore -> previous column B filter is also active!
In the documentation it states "To remove the filter again at a later time, call TMSFMXGrid.RemoveFilter;". Am I doing something wrong or is this a bug?
We have tested this here but are not able to reproduce this, can you perhaps send us a sample that is able to reproduce this? We have tested this here on our filtering demo.
just to clear things up (if anyone else is wondering about this):
I got mail from the TMS Support:
TMSFMXGrid.RemoveFilter is currently based on a single column filter, not on multi-column filter. They are investigating if they can improve the current behaviour. Calling TMSFMXGrid.Filter.Clear before the RemoveFilter will lead to the expected result.
Now I can work with it. Just wanted to leave a thanks to all people who tried to help.