jaromir Posted August 4, 2017 Share Posted August 4, 2017 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 Link to comment Share on other sites More sharing options...
Sherzod Posted August 4, 2017 Share Posted August 4, 2017 Hi, Sorry, can you clarify your question again? Link to comment Share on other sites More sharing options...
jaromir Posted August 4, 2017 Author Share Posted August 4, 2017 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 ? Link to comment Share on other sites More sharing options...
Sherzod Posted August 4, 2017 Share Posted August 4, 2017 Can you try this config?: function beforeInit(sender, config) { config.forceFit = true; } Link to comment Share on other sites More sharing options...
jaromir Posted August 4, 2017 Author Share Posted August 4, 2017 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 ? Link to comment Share on other sites More sharing options...
jaromir Posted August 4, 2017 Author Share Posted August 4, 2017 Solved. Thank You. grData.ClientEvents.UniEvents.Values['beforeInit'] := Format('function (sender, config) { if (config.width >= %d) {config.forceFit = true;} }', [grData.Columns.ColumnsWidth]); Link to comment Share on other sites More sharing options...
Marlon Nardi Posted August 4, 2017 Share Posted August 4, 2017 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(); '+ ' }) '+ ' } '; Link to comment Share on other sites More sharing options...
jaromir Posted August 4, 2017 Author Share Posted August 4, 2017 Thank You Marlon. I didn't know autosize. I wanted to forced fit only if all columns could have minimum designed size. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now