#1 2013-05-28 17:10:32

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

TSQLTableToGrid Refresh resizing columns

By default TSQLTableToGrid.Refresh auto resizes the column widths but I want to turn off this feature. Could a 'ResizeColumns' parameter be added to the function like below?

function TSQLTableToGrid.Refresh(ForceRefresh: Boolean=false; ResizeColumns: Boolean=true): boolean;
var Refreshed: boolean;
    aID: integer;
begin
  if self=nil then
    result := false else begin
    aID := Table.IDColumnHiddenValue(TDrawGrid(Owner).Row);
    if ForceRefresh then
      result := true else
      result := Client.UpdateFromServer([Table],Refreshed) and Refreshed;
    if result then
      AfterRefresh(aID, ResizeColumns);
  end;
end;

procedure TSQLTableToGrid.AfterRefresh(aID: integer, ResizeColumns: Boolean);
var CurrentRow: integer;
    Bulk: boolean;
begin
  with TDrawGrid(Owner) do begin
    if Table.RowCount=0 then
      RowCount := 2 else
      RowCount := Table.RowCount+1;
    if Table.FieldCount<>ColCount then begin
      // we get results from a void table for the first time
      ColCount := Table.FieldCount;
      SetLength(fFieldOrder,Table.FieldCount);
    end;
    CurrentRow := Table.RowFromID(aID);
    if CurrentRow=0 then
      CurrentRow := 1;
    Row := CurrentRow;
    TopRow := 1;
    Invalidate;
  end;
  if ResizeColumns then
    Resize(nil); // auto resize columns
  if Assigned(OnSelectCell) then
     OnSelectCell(Owner,0,CurrentRow,Bulk); // refresh details
end;

Offline

#2 2013-05-29 08:57:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: TSQLTableToGrid Refresh resizing columns

Could you please add a feature request ticket?

See http://synopse.info/fossil/reportlist (after anonymous login to the fossil repository)
with a link to this forum thread (for feedback and ideas)

Offline

#3 2013-06-27 06:37:32

esmondb
Member
From: London
Registered: 2010-07-20
Posts: 299

Re: TSQLTableToGrid Refresh resizing columns

Just added a ticket. Sorry initially missed your response.

Thanks

Offline

#4 2013-07-08 05:52:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: TSQLTableToGrid Refresh resizing columns

It has been implemented.

Thanks for the idea.

Offline

Board footer

Powered by FluxBB