Jump to content

Grid With Row Widget: Only Allow One Row To Be Expanded at a time - How ?


andyhill

Recommended Posts

I have a Grid with a Row Widget - ALL Good.

How do I only allow one row expanded at a time ? This would require closing previous expanded row on current expansion.

Also in code how do I expand All and Collapse All ?

Link to comment
Share on other sites

11 minutes ago, andyhill said:

How do I only allow one row expanded at a time ? This would require closing previous expanded row on current expansion.

Hello,

Haven't tried searching the forum. This has already been discussed several times.

Link to comment
Share on other sites

Asking again, please advise how to Collapse ALL RowWidgets on DBGrid.

// Collapse
procedure TfMain.grdOutlineRowCollapse(Sender: TUniCustomDBGrid; const RowId: Integer; Container: TUniContainer);
begin
  ExpandedID:= 0;
end;

// Expand
procedure TfMain.grdOutlineRowExpand(Sender: TUniCustomDBGrid; const RowId: Integer; var RowControl: TControl; Container: TUniContainer);
begin
  try
    ExpandedID:= (Sender as TUniDBGrid).DataSource.DataSet.FieldByName('OutlineID').AsInteger;
    RowControl:= TfOutlineDetail.Create(Container); 
  except
  end;
end;

// Select
procedure TfMain.grdOutlineSelectionChange(Sender: TObject);
var
  ChkID: Integer;
begin
  try
    ChkID:= (Sender as TUniDBGrid).DataSource.DataSet.FieldByName('OutlineID').AsInteger;
    if ( (ExpandedID > 0) and (ChkID <> ExpandedID) ) then begin
      grdOutline.CollapseAll();
      ExpandedID:= 0;
    end;
  except
  end;
end;

How do I Collapse ALL RowWidgets ?

grdOutline.CollapseAll();

 

Link to comment
Share on other sites

Hundreds and hundreds of records.

I was advised to use RowWidgets as there is no true Master/Detail Grid Option (I do not want two permanent grids always showing).

So using RowWidgets on Expand: the Frame has SQL data, therefore if more than one Row is expanded the SQL data is only valid on the latest expand.

This can be simply resolved by OnExpand Event closing previously expanded Row if another row was expanded.  

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