javascript - 除了 extjs 的可编辑网格中给出的更新和取消之外,添加新按钮 "Save and Next"

标签 javascript extjs

请帮忙。 我正在使用 extjs。目前我的可编辑网格有两个按钮(“更新”和“取消”)我需要添加新按钮“保存和下一步”(保存当前行并使下一行可编辑)在可编辑网格中。有人可以帮我实现这个目标吗。

最佳答案

如果你分享你的代码,那么我可以给你最好的答案。我已经编写了单击按钮时编辑行的代码(在网格中作为操作列)。在编辑代码之前,您可以编写用于将数据保存到所需位置的代码。

Ext.application({
name: 'Fiddle',

launch: function() {

    var studentStore = Ext.create('Ext.data.Store', {
        autoLoad: 'false',
        fields: [
            {name: 'studentId'},
            {name: 'name'},
            {name: 'age'}
        ],
        data:[
            {'studentId': 1, 'name': 'Puneet', 'age': 25}
        ]
    });

     cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToMoveEditor: 1,
    autoCancel: false
});


        Ext.create('Ext.window.Window', {
        title: 'Row Editing Grid',
        height: 400,
        width: 400,
        items: [{
            xtype: 'grid',
            height: 400,
            store:studentStore,
            plugins: [cellEditing],
            columns:[
                {
                    xtype: 'actioncolumn',
                    items:[
                        {
                            text:'Add New Row',
                            tooltip: 'Add Row',
                            icon: 'add.png',
                            handler: function(grid, rowIndex, colIndex){
                                grid.store.add({});
                                var rowIndex = grid.store.data.items.length - 1;
                                cellEditing.startEdit(rowIndex,1);

                            }
                        }
                    ]
                },
                {
                    header: 'StudentId',
                    dataIndex: 'studentId',
                    editor:{
                        xtype: 'textfield'
                    }
                },
                {
                    header: 'Name',
                    dataIndex: 'name',
                    editor:{
                        xtype: 'textfield'
                    }
                },
                {
                    header: 'Age',
                    dataIndex: 'age',
                    editor:{
                        xtype: 'textfield'
                    }
                }
            ]
        }]
    }).show();
}
});

关于javascript - 除了 extjs 的可编辑网格中给出的更新和取消之外,添加新按钮 "Save and Next",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844617/

相关文章:

javascript - 对 Vue 插件进行单元测试

javascript - 我正在尝试从一个数组创建新的数组数组

javascript - 在 Selenium WebDriverJS 中获取 WebElement 的 HTML 源代码

javascript - Sencha Touch2 - 带有卡片布局的面板不起作用

templates - 何时为 Ext JS 组件呈现模板 (.tpl)?

ExtJS 5 从对象创建动态面板

css - 字段显示样式,内部文本的不同字体大小

javascript - 无法从 angularjs 中的 json 文件获取数据?

javascript - 如何让父组件知道所有子组件何时加载

javascript - ExtJS 调试 "[E] Layout run failed"(在自定义组件中)