Jump to content

Manuelles Schließen eines RowWidget


bbm

Recommended Posts

Hi all,

I am using Delphi 10.2 and unuGUI version 1.90.0.1551. I have activated the RowWidget in a DBGrid

Is it possible to close an opened row widget by opening another one.

Best regards

Link to comment
Share on other sites

4 hours ago, bbm said:

Is it possible to close an opened row widget by opening another one.

Hello,

Here is the solution:

1. UniDBGrid1.ClientEvents.ExtEvents -> 

function afterrender(sender, eOpts)
{
    sender.view.rowExpander.collapseRow = function(rowIdx) {
        var rowNode = this.view.getNode(rowIdx),
            row = Ext.get(rowNode),
            nextBd = Ext.get(row).down(this.rowBodyTrSelector),
            record = this.view.getRecord(rowNode),
            grid = this.getCmp();
        if (!row.hasCls(this.rowCollapsedCls)) {
            row.addCls(this.rowCollapsedCls);
            nextBd.addCls(this.rowBodyHiddenCls);
            this.recordsExpanded[record.internalId] = false;
            this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
        }
    };
}

2. 

  private
    { Private declarations }
    FPrevRowID: Integer;

3. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  FPrevRowID := -1;
end;

4. 

procedure TMainForm.UniDBGrid1RowExpand(Sender: TUniCustomDBGrid;
  const RowId: Integer; var RowControl: TControl; Container: TUniContainer);
begin
  if FPrevRowID=-1 then
  begin
    FPrevRowID := RowId
  end
  else
  begin
    UniDBGrid1.JSInterface.JSCall('view.rowExpander.collapseRow', [FPrevRowID]);
    FPrevRowID := RowId;
  end;

  RowControl := TDetailFrame.Create(Container);

end;

5. 

procedure TMainForm.UniDBGrid1RowCollapse(Sender: TUniCustomDBGrid;
  const RowId: Integer; Container: TUniContainer);
begin
  if FPrevRowID=RowId then
    FPrevRowID := -1;

end;

 

Link to comment
Share on other sites

  • 1 year later...
On 5/26/2022 at 11:42 PM, Sherzod said:

Hello,

Here is the solution:

1. UniDBGrid1.ClientEvents.ExtEvents -> 

function afterrender(sender, eOpts)
{
    sender.view.rowExpander.collapseRow = function(rowIdx) {
        var rowNode = this.view.getNode(rowIdx),
            row = Ext.get(rowNode),
            nextBd = Ext.get(row).down(this.rowBodyTrSelector),
            record = this.view.getRecord(rowNode),
            grid = this.getCmp();
        if (!row.hasCls(this.rowCollapsedCls)) {
            row.addCls(this.rowCollapsedCls);
            nextBd.addCls(this.rowBodyHiddenCls);
            this.recordsExpanded[record.internalId] = false;
            this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
        }
    };
}

2. 

  private
    { Private declarations }
    FPrevRowID: Integer;

3. 

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  FPrevRowID := -1;
end;

4. 

procedure TMainForm.UniDBGrid1RowExpand(Sender: TUniCustomDBGrid;
  const RowId: Integer; var RowControl: TControl; Container: TUniContainer);
begin
  if FPrevRowID=-1 then
  begin
    FPrevRowID := RowId
  end
  else
  begin
    UniDBGrid1.JSInterface.JSCall('view.rowExpander.collapseRow', [FPrevRowID]);
    FPrevRowID := RowId;
  end;

  RowControl := TDetailFrame.Create(Container);

end;

5. 

procedure TMainForm.UniDBGrid1RowCollapse(Sender: TUniCustomDBGrid;
  const RowId: Integer; Container: TUniContainer);
begin
  if FPrevRowID=RowId then
    FPrevRowID := -1;

end;

 

Hi @Sherzod,

 

I tried the above (as is) works well with on-screen rows (I am using .1579) but when I left an open widget and scroll down to open another row it prompts ajax error:

image.png.e3a32435402a3e82554ff7e810630e91.png

 

Also, in Grouped dbGrid, if I open row widget on, say, group 1 then open another widget from group 2, the widget willl not expand then the rest of the row widget wont open.

Hoping for your assistance.

Thanks,

Frances

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...