I made it work thanks to Jmpessoa example.
really like how it works, and its quite flexible tool for data shoing...
Pitty cant change colours though.
Here I show you a mysql example.
Here IS HOW i POPULATE THE GRID. (variable names should be yours):
NOTICE that I didn't write conetion data (mysqlconnector, sqlquery, transaction... that you shoud arrange before check if connected)
first, define col, row:
var
row,col:integer;
begin
and later in procedure...
if MySQL56Connection1.connected then begin
jGridView1.clear;
jGridView1.Columns:=8;
row:=0;
try
SQLQuery1.close;
SQLQuery1.SQL.Text:=''YOUR QUERY')';
SQLQuery1.active:=true;
SQLQuery1.Open;
while not SQLQuery1.EOF do
begin
jGridView1.AddRow(row);
if not SQLQuery1.FieldByName('Id').isnull then jGridView1.Cells[0,row]:=SQLQuery1.FieldByName('Id').value;
if not SQLQuery1.FieldByName('numeroPedido').isnull then jGridView1.Cells[1,row]:=SQLQuery1.FieldByName('numeroPedido').value;
if not SQLQuery1.FieldByName('cliente').isnull then jGridView1.Cells[2,row]:=SQLQuery1.FieldByName('cliente').value;
if not SQLQuery1.FieldByName('referenciaCliente').isnull then jGridView1.Cells[3,row]:=SQLQuery1.FieldByName('referenciaCliente').value;
if not SQLQuery1.FieldByName('servida').isnull then jGridView1.Cells[4,row]:=SQLQuery1.FieldByName('servida').value;
if not SQLQuery1.FieldByName('forrado_hoja').isnull then jGridView1.Cells[5,row]:=SQLQuery1.FieldByName('forrado_hoja').value;
if not SQLQuery1.FieldByName('forrado_bastidor').isnull then jGridView1.Cells[6,row]:=SQLQuery1.FieldByName('forrado_bastidor').value;
if not SQLQuery1.FieldByName('material_suelto').isnull then jGridView1.Cells[7,row]:=SQLQuery1.FieldByName('material_suelto').value;
inc(row);
SQLQuery1.Next;
end;
SQLQuery1.Close;
finally
end;
end; Also, to make it easier and nicer to look. I use 2 grids. one above the other.
The first one I populate with a single row (as header).
That way when you need to repopulate data grid you can clear and dont need to repopulate headers. and Also, you can give it a different colour.
As example of header(of course, your header names):
procedure Tgps_sgtl_droid.preparagrid;
var
row,col:integer;
begin
with jGridView2 do begin
Clear;
Columns:=8;
row:=0;
jGridView2.AddRow(row);
jGridView2.Cells[0,row]:='ID';
jGridView2.Cells[1,row]:='PEDIDO';
jGridView2.Cells[2,row]:='CLIENTE';
jGridView2.Cells[3,row]:='REF CLIENTE';
jGridView2.Cells[4,row]:='SERVIDA';
jGridView2.Cells[5,row]:='FORR HOJA';
jGridView2.Cells[6,row]:='FORR BASTI';
jGridView2.Cells[7,row]:='MAT SUELTO';
end;
end; set both grids parentwidth
and second one achored to header one, anchored below. with top margin=1 (header margin.bottom=1 too).
looks quite fine.
and is easy to repopulate.
hope it helps