Good morning,
strange problem using filter with FMXGrid under android.
In a form i have the grid (filled, sorted) and 3 radio buttons.
The grid has last column (n.11) setted with "Flag" and the flag can be 1 or 2.
Here the code of all 3 radio buttons
procedure FMX_Form1.RB1Change(Sender: TObject);
begin
SG1.RemoveFilter;
SG1.Filter.Clear;
end;
procedure FMX_Form1.RB2Click(Sender: TObject);
begin
SG1.RemoveFilter;
SG1.Filter.Clear;
with SG1.Filter.Add do
begin
Column:=11;
Condition:='= 1';
end;
SG1.ApplyFilter;
end;
procedure FMX_Form1.RB3Click(Sender: TObject);
begin
SG1.RemoveFilter;
SG1.Filter.Clear;
with SG1.Filter.Add do
begin
Column:=11;
Condition:='= 2';
end;
SG1.ApplyFilter;
end;
RB1 = Radiobutton1 (ecc..)
What is happend is that if i "click" over RB2 (or RB3) nothing happend ....
The filter is not, apparently, applied, so i tap one of the other radio buttons and the filter works.
If i tap the rb2 or rb3 the filter works well, i have the grid filtered for "flag 1 o 2" but if i tab on rb1, i reset the filter (remove all filter) the grid will be without filter (i see all record, good) and if i try to set the filter again .... i'm in the starting position (the filter works only to second tap).
Did you already debug the event handlers and checked if they are actually called? Did you try with buttons instead of radiobuttons? I see you are mixing radio button change and click event handlers, both have a different behaviour
Hi Pieter,
first of all thank you for your big patience !!!
I made some test and some "code improvement" ... if i can use the term "improvement"
I remove SG1.Filter.Clear because it's already called into SG1.RemoveFilters and i used RemoveFilters instead RemoveFilter (without "S").
Regarding your suggestion, no i'm using radiobuttons .... now i do not need to use button, i tell you later.
You'e rigth ... i mixed two different events, i work with change....
But the result is the same ...
Investigating a little, i've noticed that the problem manifests at the form show and each time i reset the grid selecting the first radio button.
So i changed the way to reset the grid and the procedure who i call to clear the filters in this way (as writed above).
procedure FMX_Form1.RB1Change(Sender: TObject);
begin
SG1.RemoveFilters;
end;
procedure FMX_Form1.RB2Change(Sender: TObject); // The same for RB3
begin
SG1.RemoveFilters;
with SG1.Filter.Add do
begin
Column:=11;
Condition:='= 1';
end;
SG1.ApplyFilter;
end;
Now all works well ..
Excuse me for long message but i want to report all my changes.