PDA

View Full Version : grid.panel CheckboxModel cellModel check box STAYED CHECKED???



digidigi33
11 Apr 2013, 3:19 PM
Hi Everyone,

I am trying to build a datagrid that allows a user to TAB cell by cell and make changes... IF a change is made to the cell, I want the checkbox on the left to STAY CHECKED... What's happening now is the person is going in the cell, making a change and the checkbox isn't staying checked...

Here's the code:




/*


This file is a modified version of direct-grid.js found in the Ext JS 4 package.


Copyright (c) 2011 Sencha Inc


Contact: http://www.sencha.com/contact


GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.


If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.


*/
Ext.onReady(function() {
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);

//added model inside onready
Ext.define('PersonalInfo', {
extend: 'Ext.data.Model',
fields: ['id', 'part_no', 'tddb_retail', 'tddb_jobber']
});

//separated store into unique var for guaranteeRange
var store = Ext.create('Ext.data.Store', {
model: 'PersonalInfo',
autoLoad: true,
proxy: {
type: 'direct',
directFn: QueryDatabase.getResults,
}
});

//create a checkbox
var sm = Ext.create('Ext.selection.CheckboxModel', {
mode: 'MULTI'
})

//create the grid
var grid = Ext.create('Ext.grid.Panel', {
height: 450,
width: 700,
title: 'Item Worklist',
store: store,
tools:[{
type:'save',
tooltip: 'Save Data',
// hidden:true,
handler: function(event, toolEl, panel){
// refresh logic
}
}],
columns: [{
dataIndex: 'id',
width: 50,
text: 'ID'
}, {
dataIndex: 'part_no',
flex: 1,
text: 'Part Number',
editor: 'textfield'
}, {
dataIndex: 'tddb_retail',
flex: 1.3,
text: 'TD Retail',
editor: 'textfield'
}, {
dataIndex: 'tddb_jobber',
flex: 1,
text: 'TD Jobber',
editor: 'textfield'
}],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
selModel: sm,
renderTo: Ext.getBody(),
});
});



How can I get the check box to stayed checked? Also, if anyone can point me to the code that tells the checkbox to stay check on editing a cell, that would help a ton!

Thanks!

slemmon
13 Apr 2013, 1:48 PM
CellEditing implicitly assumes it's working with a cellmodel selectionModel type. While you could override the CellEditing class to prevent the editor from exclusively selecting the cell/row of the cell being edited that would involve overriding a private, undocumented method - not an advisable path to take.

Instead you may want to use a CheckColumn (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.grid.column.CheckColumn) or BooleanColumn (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.grid.column.Boolean) and check them programmatically keying off of the CellEditing class's edit (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.grid.plugin.CellEditing-event-edit) event.