Jump to content

Recommended Posts

Posted

Hello,

 

Is it possible to change grid forcefit property at runtime ? If so how i can achieve this.

I tried this but without luck:

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
  sender.headerCt.forceFit=true
}

Regards

Posted

ForceFit works for me only when i set up this property in design time.

At runtime (in code) set grid.forcefit := true doesn't work.

So it is possible to change forcefit in code ?

Posted

Thank You !

 

It works like expected.

I tried to turn on forcefit in code when columns width sum is less or equal than grid size.

 

Columns width sum is easy:

  TUniDBGridColumnsHelper = class helper for TUniDBGridColumns
  public
    function ColumnsWidth: Integer;
  end;

function TUniDBGridColumnsHelper.ColumnsWidth: Integer;
var
  i: Integer;
begin
  Result := 0;
  for i := 0 to Self.Count - 1 do
    if Self[i].Visible then
      Result := Result + Self[i].Width;
end;

But unfortunately I can't get grid width at code. Grid.width is the same as in design time.

Delphi Developer could You help again please ?

Posted

Solved. Thank You.

  grData.ClientEvents.UniEvents.Values['beforeInit'] :=
    Format('function (sender, config) 
      { if (config.width >= %d) {config.forceFit = true;} }',
    [grData.Columns.ColumnsWidth]);
Posted

ForceFit:
 

Grid.ClientEvents.UniEvents.Values['beforeInit'] :=
    'function (sender, config) { config.forceFit = true; }';

AutoSize:
 

Grid.ClientEvents.ExtEvents.Values['store.load'] :=
    'function (sender, records, successful, eOpts) ' +
    ' { ' +
    '   sender.grid.columnManager.columns.forEach(function(col) '+
    '   { '+
    '    col.autoSize(); '+
    '   }) '+
    ' } ';

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...