Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在extjs中为delete在控制器中写入什么_Extjs_Controller_Extjs4_Extjs Mvc_Delete Row - Fatal编程技术网

在extjs中为delete在控制器中写入什么

在extjs中为delete在控制器中写入什么,extjs,controller,extjs4,extjs-mvc,delete-row,Extjs,Controller,Extjs4,Extjs Mvc,Delete Row,我的看法 Ext.define('AM.view.emp.EDUGRID', { extend: 'Ext.grid.Panel', alias: 'widget.education', title: 'All Users', store: 'AddEdu', //id:'111', dockedItems: [{ xtype: 'toolbar', items: [{ iconCls: 'i

我的看法

Ext.define('AM.view.emp.EDUGRID', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.education',
    title: 'All Users',
    store: 'AddEdu',
    //id:'111',
    dockedItems: [{
        xtype: 'toolbar',
        items: [{
            iconCls: 'icon-add',
            text: 'Add',
            action: 'save'

        }, {
            iconCls: 'icon-delete',
            text: 'Delete',
            disabled: true,
            itemId: 'delete',
            scope: this,
            action: 'Del'
        }]
    }],
    initComponent: function () {

        this.columns = [{
            header: 'Level',
            dataIndex: 'Level',
            flex: 1
        }, {
            header: 'institute',
            dataIndex: 'institute',
            flex: 1
        }, {
            header: 'specialization',
            dataIndex: 'specialization',
            flex: 1
        }, {
            header: 'YoP',
            dataIndex: 'YoP',
            flex: 1
        }]

        this.callParent(arguments);
        this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
    },
    onSelectChange: function (selModel, selections) {
        this.down('#delete').setDisabled(selections.length === 0);
    }
});
Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',
    stores: ['Users', 'Nationality', 'Maritalstatus', 'Empcat', 'Designation', 'Department', 'AddEdu'],
    models: ['User',
        'nationality',
        'maritalstatus',
        'empcat', 'designation', 'department', 'AddEdu'],
    views: [
        'user.List',
        'user.Edit',
        'emp.PD',
        'emp.JD', 'emp.WE',
        'emp.EDUGRID',
        'emp.eduform'],

    init: function () {
        this.control({

            'education button[action=save]': {

                click: this.EduQ
            },
            'edu button[action=save]': {
                click: this.UpdateEdu
            },
            'education button[action=Del] ': {
                click: function (grid, cell, row, col, e) {
                    var rec = this.grid.getStore().getAt(row);
                }
            }
        });
    },   
单击del按钮后,它会转到控制器,我必须在其中指定删除操作。但我不确定在delete函数中提供什么。 这是我的控制器

Ext.define('AM.view.emp.EDUGRID', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.education',
    title: 'All Users',
    store: 'AddEdu',
    //id:'111',
    dockedItems: [{
        xtype: 'toolbar',
        items: [{
            iconCls: 'icon-add',
            text: 'Add',
            action: 'save'

        }, {
            iconCls: 'icon-delete',
            text: 'Delete',
            disabled: true,
            itemId: 'delete',
            scope: this,
            action: 'Del'
        }]
    }],
    initComponent: function () {

        this.columns = [{
            header: 'Level',
            dataIndex: 'Level',
            flex: 1
        }, {
            header: 'institute',
            dataIndex: 'institute',
            flex: 1
        }, {
            header: 'specialization',
            dataIndex: 'specialization',
            flex: 1
        }, {
            header: 'YoP',
            dataIndex: 'YoP',
            flex: 1
        }]

        this.callParent(arguments);
        this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
    },
    onSelectChange: function (selModel, selections) {
        this.down('#delete').setDisabled(selections.length === 0);
    }
});
Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',
    stores: ['Users', 'Nationality', 'Maritalstatus', 'Empcat', 'Designation', 'Department', 'AddEdu'],
    models: ['User',
        'nationality',
        'maritalstatus',
        'empcat', 'designation', 'department', 'AddEdu'],
    views: [
        'user.List',
        'user.Edit',
        'emp.PD',
        'emp.JD', 'emp.WE',
        'emp.EDUGRID',
        'emp.eduform'],

    init: function () {
        this.control({

            'education button[action=save]': {

                click: this.EduQ
            },
            'edu button[action=save]': {
                click: this.UpdateEdu
            },
            'education button[action=Del] ': {
                click: function (grid, cell, row, col, e) {
                    var rec = this.grid.getStore().getAt(row);
                }
            }
        });
    },   
我应该在EduD里面放什么

    EduD: function (view, cell, row, col, e) {
           var record = this.getGrid().store.getAt(row)
           this.deleteRecord([record])
       },

       EduQ: function (grid, record) {
           var view = Ext.widget('edu');
       },

       UpdateEdu: function (button) {
           var win = button.up('window');
           var form = win.down('form').getForm();
           if (form.isValid()) {
               var record = form.getRecord();
               var values = form.getValues();
               if (!record) {
                   var newRecord = new AM.model.AddEdu(values);
                   this.getAddEduStore().add(newRecord);
               } else {
                   record.set(values);
               }
               win.close();
           }
       }
});

您只需从存储中删除记录,然后如果要将其同步到数据库,请调用
store.sync()

例如:

//Your listener can change to this:
'education button[action=Del] ': {
                this.EduD
}

//The callback function:
EduD: function (view, cell, row, col, e) {
       var store = view.getStore(); //You can access the store from the view
       var record = store.getAt(row); //Get the clicked record
       store.remove(record); //Remove the record from the store
       store.sync(); //Sync the store
},
网格应该是这样的

控制器应该是

取消休假看起来是这样的

cancelLeave: function (view, cell, rowIndex, colIndex, e, record, row) {

            Ext.Msg.confirm('Remove Qualification', 'Are you sure?', function (button) {
        if (button == 'yes') {
            var store = Ext.getStore('LeaveRequest');
           var newRecord = new AM.model.leaverequest(row);
           console.log(record);
           console.log(store);
           store.remove(record);
           store.sync();
        }
    }, this);

请帮助..我很困惑..这是在添加按钮中触发事件