0

I have a grid with records from a store using the modern material theme on ExtJS 7.2. I want to create multiple floating, draggable formpanels from this view, but when I drag the formpanel around, closing it leaves a blank white space where the formpanel was, obscuring the background. Here is the source for the formpanel.

onItemClick: function (grid,rowIndex,e) {
    var record = grid.getStore().getAt(rowIndex);
    var form = Ext.create({
        xtype: 'formpanel',
        id: `${record.id}_form_${record.get('blah')}`,
        title: `Invoice ${record.get('blah')}`,
        floating: true,
        closable: true,
        centered: true,
        draggable: true,
        shadow: true,
        width:300,
        height:window.innerHeight*0.8,
        scrollable: true,
        modal: null,
        items: [
            {
                xtype: 'textfield',
                name: 'Blah',
                label: 'Blah',
                value: record.get('blah'),
            },
            {
                xtype: 'toolbar',
                docked: 'bottom',
                items: [{
                    xtype: 'button',
                    text: 'Save',
                    ui: 'raised round',
                    iconCls: 'x-fa fa-save',
                    handler: function() {
                        var theform = this.up('formpanel').getFields();
                        record.set(
                            {
                                'blah': theform['Blah'].getValue(),
                            }
                        );
                        this.up('formpanel').destroy();
                    }
                },'->', {
                    xtype: 'button',
                    text: 'Cancel',
                    ui: 'raised round',
                    iconCls: 'x-fa fa-close',
                    handler: function() {
                        this.up('formpanel').destroy();
                    },
                }]
            }
        ]
    });
    Ext.Viewport.add(form);
}

Does anyone have experience with this problem? I have tried messing around with a custom Ext.drag.Source object, but with no success so far. When I try to close a formpanel that has been dragged, I get an error:

TypeError: Argument 1 of Node.replaceChild is not an object.

Any help would be appreciated.

1 Answers1

0
  1. there is not property called "floating" in the modern toolkit. Did you mean "floated"?
  2. Instead of adding to Viewport better use show() method.

Something like this:

onItemClick: function (grid,rowIndex,e) {
    var record = grid.getStore().getAt(rowIndex);
    var form = Ext.create({
        xtype: 'formpanel',
        id: `${record.id}_form_${record.get('blah')}`,
        title: `Invoice ${record.get('blah')}`,
        floated: true, // It is not called "floating"
        closable: true,
        centered: true,
        draggable: true,
        shadow: true,
        width:300,
        height:window.innerHeight*0.8,
        scrollable: true,
        modal: null,
        items: [
            {
                xtype: 'textfield',
                name: 'Blah',
                label: 'Blah',
                value: record.get('blah'),
            },
            {
                xtype: 'toolbar',
                docked: 'bottom',
                items: [{
                    xtype: 'button',
                    text: 'Save',
                    ui: 'raised round',
                    iconCls: 'x-fa fa-save',
                    handler: function() {
                        var theform = this.up('formpanel').getFields();
                        record.set(
                            {
                                'blah': theform['Blah'].getValue(),
                            }
                        );
                        this.up('formpanel').destroy();
                    }
                },'->', {
                    xtype: 'button',
                    text: 'Cancel',
                    ui: 'raised round',
                    iconCls: 'x-fa fa-close',
                    handler: function() {
                        this.up('formpanel').destroy();
                    },
                }]
            }
        ]
    });
    form.show(); // Show instead of add to Viewport.
    //Ext.Viewport.add(form);
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Arthur Rubens
  • 4,626
  • 1
  • 8
  • 11