Как добавить Ext.grid.CheckColumn в Ext.grid.EditorGridPanel динамически?
Дрозофилка:
Ext.onReady(function() { Ext.QuickTips.init(); var store = new Ext.data.JsonStore({ url: "DataSource.aspx", root: "rows", idProperty: "Id", successProperty: "success", totalProperty: "count", fields: [ { name: "Id", type: "int" }, "Name", { name: "Salary", type: "float" }, { name: "BirthDate", type: "date", dateFormat: "c" }, { name: "Checked", type: "boolean" } ], writer: new Ext.data.JsonWriter(), autoSave: false, batch: true, listeners: { load: function(s, r, o) { OnLoad(grid, checkColumn, store, cm) } } }), combo = new Ext.form.ComboBox({ id: "perpage", name: 'perpage', width: 40, store: new Ext.data.ArrayStore({ fields: ['id'], data: [ ['2'], ['4'], ['6'] ] }), mode: 'local', value: '2', listWidth: 40, triggerAction: 'all', displayField: 'id', valueField: 'id', editable: false, forceSelection: true }), bbar = new Ext.PagingToolbar({ pageSize: 2, store: store, displayInfo: true, items: [ "-", "Per page: ", combo ], displayMsg: 'Displaying items {0} - {1} of {2}', emptyMsg: "No items found" }), NameEdit = new Ext.form.TextField(), SalaryEdit = new Ext.form.NumberField(), BirthDateEdit = new Ext.form.DateField({ format: "d/m/Y" }), checkColumn = new Ext.grid.CheckColumn({ header: "Checked", dataIndex: "Checked", width: 50 }), cm = new Ext.grid.ColumnModel({ columns: [ { dataIndex: "Id", header: "ID", width: 30, sortable: true, hidden: true }, { id: "ColName", dataIndex: "Name", header: "Name", editor: NameEdit, width: 180, sortable: true }, { dataIndex: "Salary", header: "Salary", editor: SalaryEdit, width: 75, sortable: true, align: "center" }, { dataIndex: "BirthDate", header: "BirthDate", renderer: Ext.util.Format.dateRenderer("d/m/Y"), editor: BirthDateEdit, width: 100, sortable: true, align: "center" }, checkColumn //{ dataIndex: "Checked", header: "Checked", xtype: "booleancolumn", width: 50, sortable: true, align: "center" } ] }), grid = new Ext.grid.EditorGridPanel({ id: "TestGrid", title: "TestGrid", plugins: [], //plugins: checkColumn, clickstoEdit: 1, store: store, //cm: cm, //autoExpandColumn: "ColName", columns: [], width: 600, height: 200, tbar: { items: [ { text: 'Save Changes', handler: function() { store.save(); } } ] }, bbar: bbar }), viewport = new Ext.Viewport({ layout: 'border', renderTo: Ext.getBody(), items: [{ region: 'north', xtype: 'panel' }, { region: 'center', xtype: 'panel', items: grid }] }); combo.on('select', function(combo, record) { bbar.pageSize = parseInt(record.get('id'), 10); bbar.doLoad(bbar.cursor); }, this); store.load({ params: { start: 0, limit: parseInt(Ext.getCmp("perpage").getValue(), 10) } }); }); function OnLoad(grid, checkColumn, store, cm) { //grid.plugins = checkColumn; grid.plugins.push(checkColumn); checkColumn.init(grid); grid.reconfigure(store, cm); } Ext.grid.CheckColumn добавляется, но не редактируется... |
Попробовал сделать по аналогии как это стандартно делается:
Код:
grid.plugins=grid.initPlugin(checkColumn); init : function(grid){ this.grid = grid; this.grid.on('render', function(){ var view = this.grid.getView(); view.mainBody.on('mousedown', this.onMouseDown, this); }, this); } - вызывается. Но, вот, onMouseDown, похоже, - не прикручивается. Почему? |
Цитата:
grid.plugins=grid.initPlugin(checkColumn); grid.getView().mainBody.on('mousedown', checkColumn.onMouseDown, checkColumn); и все зафунциклировало... |
Часовой пояс GMT +3, время: 00:03. |