You are not logged in.
Pages: 1
Hi,
i try to set a TAdvGridDropDown to lookup a TSQLRecord'ID value in another TSQLRecord.
i use something like this
ElencoGroupRight := Client.MultiFieldValues(TSQLAuthGroup, '');
GrigliaGroupRight := TSQLTableToGrid.Create(GRIDGroupRight.Grid, ElencoGroupRight, Client);
and the grid is correctly populated but i cant select any row.
while if i populate the grid by hand like the tms example
GRIDGroupRight.Grid.RowCount := 8;
GRIDGroupRight.Grid.ColCount := 2;
GRIDGroupRight.Grid.Cells[0,0] := 'Number';
GRIDGroupRight.Grid.Cells[1,0] := 'Name';
GRIDGroupRight.Grid.Rows[1].CommaText := '1,Monday';
GRIDGroupRight.Grid.Rows[2].CommaText := '2,Tuesday';
GRIDGroupRight.Grid.Rows[3].CommaText := '3,Wednesday';
GRIDGroupRight.Grid.Rows[4].CommaText := '4,Thursday';
GRIDGroupRight.Grid.Rows[5].CommaText := '5,Friday';
GRIDGroupRight.Grid.Rows[6].CommaText := '6,Saturday';
GRIDGroupRight.Grid.Rows[7].CommaText := '7,Sunday';
the AdvGridDropDown work perfectly.
Can you help me?
Thanks a lot and excuse for my bad english,
Emanuele.
Offline
I think TAdvGridDropDown override some events of the Grid components.
So TSQLTableToGrid does not work as expected.
In fact, TSQLTableToGrid is aimed to work only with a plain standard TDrawGrid, not a grid embedded inside another component.
You can use the GRIDGroupRight.Grid.Rows[] or Cells[] properties to populate the TAdvGridDropDown grid from the data retrieved, with a for .... loop.
It will be slower, but it will work:
GRIDGroupRight.Grid.RowCount := ElencoGroupRight.RowCount+1;
GRIDGroupRight.Grid.ColCount := 2;
GRIDGroupRight.Grid.Cells[0,0] := 'Number';
GRIDGroupRight.Grid.Cells[1,0] := 'Name';
for i := 1 to ElencoGroupRight.RowCount do
begin
GRIDGroupRight.Grid.Cells[0,i] := ElencoGroupRight.GetString(i,0);
GRIDGroupRight.Grid.Cells[1,i] := ElencoGroupRight.GetString(i,1);
end;
Of course, it could be a good idea to make this a global function, ready to be reused.
Offline
yes, i thinked about this solution.
and write a function integrated in the framework can be a good idea?
thanks for the support,
Emanuele.
Offline
Good idea.
I've added a new FillStringGrid() function, ready to fill a regular TStringGrid.
Offline
a simple and rapid version of the procedure...maybe can help for other user.
thanks again!
procedure loadLookupGrid(var LookupGrid: TAdvGridDropDown; Tabella: TSQLRecordClass; Client: TSQLRestClientURI);
var Elenco: TSQLTableJSON;
I: Integer;
J: Integer;
begin
Elenco := Client.MultiFieldValues(Tabella, '');
LookupGrid.Columns.Clear;
LookupGrid.Grid.FloatFormat := '%.0f';
LookupGrid.UseItems := False;
LookupGrid.BeginUpdate;
LookupGrid.Grid.RowCount := Elenco.RowCount+1;
LookupGrid.Grid.ColCount := Elenco.FieldCount;
for I := 0 to Elenco.FieldCount-1 do
begin
LookupGrid.Grid.Cells[I,0] := Tabella.RecordProps.Fields[i].ShortName;
end;
for J := 0 to Elenco.RowCount do
begin
for I := 0 to Elenco.FieldCount-1 do
begin
LookupGrid.Grid.Cells[i,j] := Elenco.GetString(j,i);
end;
end;
LookupGrid.EndUpdate;
end;
Offline
yes i forget sorry!
Offline
Pages: 1