#1 2011-09-22 13:03:18

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Refreshing TSQLTableToGrid

hallo..,

what is exactly method to use to refreshing data in the grid using TSQLTableToGrid

i have the code like this :

procedure TFrameMain.RefreshNumber;
begin
  fTable2:= MainForm.Client.ListFmt([TSQLNumber2],
    FormatUTF8(aSelect,['Number2','Number2','Number2','Number2']),aWC,[fMasterCodeID]);
  fGrid2:= TSQLTableToGrid.Create(dg2,fTable2,MainForm.Client);
  fGrid2.OnDrawCellBackground:=DoDrawCell;
  with fGrid2 do begin
    SortForce(1,False);
    SetFieldFixedWidth(40);
    SetFieldLengthMean('caaa',False);
  end;
  with dg2 do begin
    ColWidths[ColCount-2]:= 20;
    ColWidths[ColCount-1]:= 20;
    Row:= 1;
  end;

  fTable3:= MainForm.Client.ListFmt([TSQLNumber3],
    FormatUTF8(aSelect,['Number3','Number3','Number3','Number3']),aWC,[fMasterCodeID]);
  fGrid3:= TSQLTableToGrid.Create(dg3,fTable3,MainForm.Client);
  fGrid3.OnDrawCellBackground:=DoDrawCell;
  with fGrid3 do begin
    SortForce(1,False);
    SetFieldFixedWidth(40);
    SetFieldLengthMean('caaa',False);
  end;
  with dg3 do begin
    ColWidths[ColCount-2]:= 20;
    ColWidths[ColCount-1]:= 20;
    Row:= 1;
  end;

  fTable4:= MainForm.Client.ListFmt([TSQLNumber4],
    FormatUTF8(aSelect,['Number4','Number4','Number4','Number4']),aWC,[fMasterCodeID]);
  fGrid4:= TSQLTableToGrid.Create(dg4,fTable4,MainForm.Client);
  fGrid4.OnDrawCellBackground:=DoDrawCell;
  with fGrid4 do begin
    SortForce(1,False);
    SetFieldFixedWidth(50);
    SetFieldLengthMean('caaa',False);
  end;

  with dg4 do begin
    ColWidths[ColCount-3]:= 40;
    ColWidths[ColCount-2]:= 20;
    ColWidths[ColCount-1]:= 20;
    Row:= 1;
  end;
end;

Where Clause parameter is fMasterCodeID, as shown above. This procedure is work as expected, except flicker on the grid.
i want more smooth and no flicker.
i tried use something like fGrid4.Refresh, and fGrid4.refresh(true) but not work.


many thanks.

Offline

#2 2011-09-22 14:48:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,183
Website

Re: Refreshing TSQLTableToGrid

I think you're recreating every content everytime... this is not the way to do it.

You'll have to add a timer to call fGrid4.Refresh and update the content only if Refreshed as been returned as TRUE.

Offline

#3 2011-09-22 18:52:10

coblongpamor
Member
From: Bali-Indonesia
Registered: 2010-11-07
Posts: 130
Website

Re: Refreshing TSQLTableToGrid

but, i want to refresh the content of the grid immediately after the fMasterCodeID changed.

i changed the name of the procedure above to TFrameMain.InitNumber and execute only one time on then constructor TFrameMain.Create.

and i create new procedure for refreshing/requery content when the fMasterCodeID changed.

procedure TFrameMain.RefreshNumber;
begin
  fTable2:= fClient.ListFmt([TSQLNumber2],
    FormatUTF8(aSelect,['Number2','Number2','Number2','Number2']),aWC,[fMasterCodeID]);
  if fGrid2.Refresh(True) then
    fGrid2.Refresh;
end;

but still not working..

Offline

Board footer

Powered by FluxBB