Jump to content

DBGrid width issue when Flex = 1 on column


Allen

Recommended Posts

Hi;

I have a DBGrid with several columns.  when using the flex attribute to expand columns to fill the width of the grid, instead of utilizing the available width, the data rows become small, and lose their orientation with their headers.  The flex attribute seems to be correctly applied the the header.  In my screenshot the Flex = 1 attribute is applied to 1, 2 & 3.

Any suggestions gratefully appreciated.

 

Screenshot 2022-02-15 215506.png

Link to comment
Share on other sites

1 hour ago, Allen said:

I have a DBGrid with several columns.  when using the flex attribute to expand columns to fill the width of the grid, instead of utilizing the available width, the data rows become small, and lose their orientation with their headers.  The flex attribute seems to be correctly applied the the header.  In my screenshot the Flex = 1 attribute is applied to 1, 2 & 3.

Any suggestions gratefully appreciated.

Hello,

Which build of UniGUI are you using?

I couldn't reproduce your issue.

Can you make a simple testcase to check?

Link to comment
Share on other sites

Hi;

I am using UniGui 1.90.0.1557
Delphi 11

I went to one of your demo apps and adjusted the Flex attribute and the project appearance is as expected.  

My project structure is as follows:

Main form has a UniPanel that has UniFrames loaded into it.

As best I can tell my grids settings match the demo, I will attempt to build a simple demo that has the behavior I am seeing.  The components in use are MyDac, TUniFrame, TUniDBGrid.  

Will get back to you as soon as I have a testcase.

 

Link to comment
Share on other sites

  • 3 weeks later...

Sherzod;

 

In trying to build a standalone testcase for this, If I use a clientdataset with embedded data then this always seems to work as intended.  However in my app I am using the Devart UniDAC components with MySQL and keep reverting back to the behavior highlighted above.  What is the best way to send you a project the has the behavior I am experiencing?

I have resorted to the following in my frame to arrive at a usable short term solution

procedure TDashboard.UniFrameBeforeReady(Sender: TObject);
var
  FlexGridWidth, i: Integer;
begin
  UniMainModule.SetDBUpdcomp(MyQuery1, 'TlogHttp.UniFrameBeforeReady');

  MyQuery1.SQL.Text := 'SELECT idAppLog,logTime,logLevel,session,UserId,Method,referer,uri,info '
    + ' FROM frlog order by idAppLog desc;';

  UniDataSource1.DataSet := MyQuery1;
  UniDataSource1.Enabled := true;
  UniDBGrid1.DataSource := UniDataSource1;
  UniDBGrid1.Columns.Items[0].Width := 64;
  UniDBGrid1.Columns.Items[1].Width := 64;
  UniDBGrid1.Columns.Items[2].Width := 64;
  UniDBGrid1.Columns.Items[3].Width := 64;
  UniDBGrid1.Columns.Items[4].Width := 64;
  UniDBGrid1.Columns.Items[5].Width := 64;
  UniDBGrid1.Columns.Items[6].Width := 64;
  UniDBGrid1.Columns.Items[7].Width := 64;
  
  FlexGridWidth := UniDBGrid1.Width;
  for i := 0 to UniDBGrid1.Columns.Count - 2 do
  begin
    if UniDBGrid1.Columns.Items[i].Visible then
      FlexGridWidth := FlexGridWidth - UniDBGrid1.Columns.Items[i].Width;
      UniDBGrid1.Columns.Items[i].
  end;

  UniDBGrid1.Columns.Items[8].Width := FlexGridWidth;
  // UniDBGrid1.Columns.Items[8].Flex := 1;

  MyQuery1.Open;
end;

In the code above UniDBGrid1.Columns.Items[8].Width is slightly narrower that the available space on the frame / grid.  Is there a better way to compute the available width for the "Flex" column?

-Allen

Link to comment
Share on other sites

SOLVED

The column flex attribute can not be set at design time from the object inspector, instead when set from the grids ClientEvents.ExtEvents.reconfigure as:

function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts)
{
  sender.columnManager.columns[8].flex=1;
}

then all works as expected

Link to comment
Share on other sites

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...