码迷,mamicode.com
首页 > 其他好文 > 详细

Ext 4.2 RowEditing

时间:2015-06-17 19:48:53      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

        Follow: function () {
            Ext.define(‘Follow‘, {
                extend: ‘Ext.data.Model‘,
                idProperty: ‘id‘,
                fields: [
                    { name: ‘id‘, type: ‘int‘ },
                    { name: ‘name‘, type: ‘string‘ },
                    { name: ‘Explain‘, type: ‘string‘ },
                    { name: ‘Sequence‘, type: ‘int‘ }
                ]
            });

            var rowEditing = Ext.create(‘Ext.grid.plugin.RowEditing‘, {
                clicksToEdit: 1,   //单击
                clicksToMoveEditor: 1,   //单击移动修改栏
                autoCancel: false,
                saveBtnText: ‘保存‘,
                cancelBtnText: ‘取消‘
            });

            var store = Ext.create(‘Ext.data.Store‘, {
                autoDestroy: true,
                model: ‘Follow‘,
                proxy: {
                    type: ‘ajax‘,
                    url: ‘/data/Settings/CustomerSettingHandler.ashx?action=follow‘,
                    reader: {
                        type: ‘json‘,
                        root: ‘rows‘,
                    }
                },
                listeners: {
                    update: function (store, record) {
                        var jsondate = record.get("id") + "|" + record.get("name") + "|" + record.get("Explain") + "|"
                        + record.get("Sequence");
                        $.post(‘/data/Settings/CustomerSettingHandler.ashx‘, { action: ‘followSubmit‘, json: jsondate }, function (data) {
                            if (data !== "ok") {
                                Ext.Msg.alert("提示", ‘操作失败!‘);
                                store.load();
                            }
                        });
                    },
                    remove: function (store, record) {
                        var id = record.get("id");
                        if (id == 0) {
                            return;
                        }
                        $.post(‘/data/Settings/CustomerSettingHandler.ashx‘, { action: ‘followDelete‘, json: id }, function (data) {
                            if (data !== "ok") {
                                Ext.Msg.alert("提示", ‘操作失败!‘);
                                store.load();
                            }
                        });
                    }
                },
                autoLoad: true
            });

            var grid = Ext.create(‘Ext.grid.Panel‘, {
                title: "跟进方式",
                floatable: false,
                border: false,
                store: store,
                columns: [
                    new Ext.grid.RowNumberer({ text: "序号", width: 50 }),
                    {
                        header: ‘跟进方式‘,
                        dataIndex: ‘name‘,
                        flex: 2,
                        editor: {
                            allowBlank: false
                        }
                    }, {
                        header: ‘说明‘,
                        dataIndex: ‘Explain‘,
                        flex: 2,
                        editor: {
                        }
                    }, {
                        header: ‘排序‘,
                        dataIndex: ‘Sequence‘,
                        flex: 1,
                        editor: {
                            xtype: ‘numberfield‘,
                            allowBlank: false,
                            minValue: 1,
                            maxValue: 150000
                        }
                    }, {
                        header: ‘删除‘,
                        xtype: ‘actioncolumn‘,
                        flex: 1,
                        sortable: false,
                        menuDisabled: true,
                        items: [{
                            icon: ‘/images/delete.gif‘,
                            tooltip: ‘删除‘,
                            handler: function (grid, rowIndex) {
                                var sm = grid.getSelectionModel();
                                grid.getStore().removeAt(rowIndex);
                                if (grid.getStore().getCount() > 0) {
                                    sm.select(0);
                                }
                            }
                        }]
                    }],
                plugins: [rowEditing],
                selModel: {
                    selType: ‘cellmodel‘
                },
                tbar: [{
                    text: ‘增加‘,
                    handler: function () {
                        rowEditing.cancelEdit();
                        var rec = Ext.create("Follow", {
                            Id: 0,
                            name: ‘跟进方式‘,
                            Explain: ‘说明‘,
                            Sequence: 1
                        });
                        grid.getStore().insert(0, rec);
                        rowEditing.startEdit(0, 0);
                    }
                }]

            });
            return grid;
        },

 

Ext 4.2 RowEditing

标签:

原文地址:http://www.cnblogs.com/Celebrator/p/4584036.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!