Reputation: 29
I wrote an Android application using Fire Monkey with Delphi RAD Studio 11 Version 28.0.47991.2819. In this application, I also have a grid that has columns and when the grid is defined, their index of columns is fixed. When the user click on the header of a column, depending on its index number, I change the order of displaying the information with a query. But I also allowed the user to choose the title, width, alignment and whether to display the column. After he hides the columns, the index values change.
I also tried the original index value, which also changes. I also tried to set the tag value for the column equal to its original index, but when used, the tags value also becomes zero. Do you know a solution?
procedure TDebitCheckForm.DGridHeaderClick(Column: TColumn);
Var
_ColNo:Integer;
begin
_ColNo:=Column.OriginalIndex;
With FDBs.QDebits Do
Begin
Close;
SQL.Clear;
SQL.Add(DSql);
SQL.Add(DWhere);
Case _ColNo Of
0 : DOrder:=' Order By A.DebitID';
1 : DOrder:=' Order By A.DebitDate';
19 : DOrder:=' Order By A.ToPartner';
20 : DOrder:=' Order By G.PNSort';
21 : DOrder:=' Order By G.PartnerGrp';
22 : DOrder:=' Order By H.PGNSort';
23 : DOrder:=' Order By G.CartNo1';
24 : DOrder:=' Order By G.CartNo2';
25 : DOrder:=' Order By G.AccNo1';
26 : DOrder:=' Order By G.AccNo2';
27 : DOrder:=' Order By G.ShebaNo1';
28 : DOrder:=' Order By G.ShebaNo2';
29 : DOrder:=' Order By G.Mobile';
End;
SQL.Add(DOrder);
Open;
End;
End;
The problem is that if the user hides a column, then the column index gets messed up.
Upvotes: 0
Views: 63