Jump to content

How To prevent dbGrid RowWidget from "Collapse"?


fraxzi

Recommended Posts

Hi Everyone,

My dbGrid has RowWidget (Master/Detail) ... a clientdataset has pending updates.

I would like to limit the collapse of RowWidget unless user click the save button.

Thanks in advance,

Frances

Link to comment
Share on other sites

Just now, Sherzod said:

Hi,

Can you please explain in more detail?

Hi Sherzod,

RowWidget has dbGrid (ClientDataSet) any update (by end-user) are not applied when RowWidget collapsed.. How to prevent the RowWidget from closing?

 

Thanks.

Link to comment
Share on other sites

13 minutes ago, fraxzi said:

RowWidget has dbGrid (ClientDataSet) any update (by end-user) are not applied when RowWidget collapsed.. How to prevent the RowWidget from closing?

If possible, create a simple testcase, I will try to analyze it on your testcase.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...
  • 3 months later...
  • 2 years later...

Hello @fraxzi

Let's start with some solutions.

You can process it first on the client side to prevent it from collapsing if the grid is in the editing state.

1. 

procedure TDetailFrame.UniFrameDestroy(Sender: TObject);
begin
 //Somewhere to prevent collapse of RowWidget if ClientDataSet has changes....???
 //MessageDlg('There Are Changes... Save Data Entry?', mtConfirmation, mbYesNoCancel, uMsgCallBack);
end;

2. MainForm.Script ->

Ext.onReady(function() {
    Ext.override(Ext.grid.plugin.RowWidget, {
        toggleRow: function(rowIdx, record) {
            if (record && record.node) {
                var _nestedgrid = Ext.get(record.node).query('.x-grid')[0];
                if (_nestedgrid) {
                    var _editingPlugin = Ext.getCmp(_nestedgrid.id).editingPlugin;
                    if (_editingPlugin && _editingPlugin.editing === true) {
                        return false
                    }
                }
            }
            this.callParent(arguments);
        }
    })
})

 

Link to comment
Share on other sites

12 hours ago, Sherzod said:

Hello @fraxzi

Let's start with some solutions.

You can process it first on the client side to prevent it from collapsing if the grid is in the editing state.

1. 

procedure TDetailFrame.UniFrameDestroy(Sender: TObject);
begin
 //Somewhere to prevent collapse of RowWidget if ClientDataSet has changes....???
 //MessageDlg('There Are Changes... Save Data Entry?', mtConfirmation, mbYesNoCancel, uMsgCallBack);
end;

2. MainForm.Script ->

Ext.onReady(function() {
    Ext.override(Ext.grid.plugin.RowWidget, {
        toggleRow: function(rowIdx, record) {
            if (record && record.node) {
                var _nestedgrid = Ext.get(record.node).query('.x-grid')[0];
                if (_nestedgrid) {
                    var _editingPlugin = Ext.getCmp(_nestedgrid.id).editingPlugin;
                    if (_editingPlugin && _editingPlugin.editing === true) {
                        return false
                    }
                }
            }
            this.callParent(arguments);
        }
    })
})

 

Hi @Sherzod,

 

I tried the above. The RowWidget still collapse then the messagedlg (with callbackl) prompts.

Would it be possible to disable the collapse button and enable it when needed?

Thanks for the usual assistance.

-Frances

 

Link to comment
Share on other sites

53 minutes ago, fraxzi said:

The RowWidget still collapse then the messagedlg (with callbackl) prompts.

 

12 hours ago, Sherzod said:
procedure TDetailFrame.UniFrameDestroy(Sender: TObject);
begin
 //Somewhere to prevent collapse of RowWidget if ClientDataSet has changes....???
 //MessageDlg('There Are Changes... Save Data Entry?', mtConfirmation, mbYesNoCancel, uMsgCallBack);
end;

 

Link to comment
Share on other sites

3 hours ago, fraxzi said:

I tried the above. The RowWidget still collapse then the messagedlg (with callbackl) prompts.

Because this is already another event.

2 hours ago, Sherzod said:
UniFrameDestroy

 

Link to comment
Share on other sites

3 hours ago, fraxzi said:

Would it be possible to disable the collapse button and enable it when needed?

Yes,

You can keep a variable either on the client side or on the server side, and checking this variable in the toggleRow method...

Link to comment
Share on other sites

2 hours ago, fraxzi said:

toggleRow

 

On 1/28/2024 at 6:26 PM, Sherzod said:

MainForm.Script ->

Ext.onReady(function() {
    Ext.override(Ext.grid.plugin.RowWidget, {
        toggleRow: function(rowIdx, record) {
            if (record && record.node) {
                var _nestedgrid = Ext.get(record.node).query('.x-grid')[0];
                if (_nestedgrid) {
                    var _editingPlugin = Ext.getCmp(_nestedgrid.id).editingPlugin;
                    if (_editingPlugin && _editingPlugin.editing === true) {
                        return false
                    }
                }
            }
            this.callParent(arguments);
        }
    })
})

 

Link to comment
Share on other sites

20 hours ago, Sherzod said:

@fraxzi

Tell me again what needs to be done?

Controlling row collapsing based on a boolean variable?

Hi @Sherzod,

 

I tried the above but still I couldn't implement. Perhaps the easiest is to enable/disable the expand button?

Thanks for your persistent help.

-Frances

Link to comment
Share on other sites

Ok @fraxzi try this approach:

1. MainForm.Script ->

Ext.onReady(function() {
    Ext.override(Ext.grid.plugin.RowWidget, {
        toggleRow: function(rowIdx, record) {
            if (this.grid.expanderDisabled && this.grid.expanderDisabled === true) {
                return false
            }
            this.callParent(arguments);
        }
    })
})

2. Usage:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniDBGrid1.JSInterface.JSAssign('expanderDisabled', [True]); // True, False
end;

 

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