I have a tab
, named "Schema"
, that renders a grid
. One of the grid columns is checkcolumn
type. What values should I pass to the store when I render my grid, so I have some of the checkboxes checked and others not checked? It must be something really trivial, but I couldn't find a solution so far.
Here is a simplified structure of the grid and the checkcolumn:
{
title: 'Schema',
listeners: {
activate: function(tab) {
myNmsps.renderSchema();
}
},
id: 'schemaTab',
items: [{
xtype: 'grid',
id: 'schema',
border: false,
data: [],
columns: [
{
text: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield',
isEditable: true,
}
},{
text: 'Position',
dataIndex: 'position',
editor: {
xtype: 'combobox',
id: 'position',
}
}, {
text: 'Type',
dataIndex: 'type',
id: "TypeDropdown",
editor: {
xtype: 'combobox',
id: 'SelectType',
}
}, {
text: 'Size',
dataIndex: 'size',
id: "SizeDropdown",
editor: {
xtype: 'combobox',
id: 'SelectSize',
}
}, {
text: 'FilteringType',
dataIndex: 'filteringType',
editor: {
xtype: 'combobox',
id: 'filteringType',
}
}, {
xtype:'checkcolumn',
fieldLabel: 'checkboxIsUnique',
name: 'checkboxIsUnique',
text: 'Is Unique',
id: 'checkboxIsUniqueID',
dataIndex : 'checkboxIsUniqueIDX',
listeners:{
checkchange: function(column, rowIdx, checked, eOpts){
var schemaStore = Ext.getCmp('schema').getStore();
schemaStore.each(function(record,idx){
if(rowIdx == idx && checked===true){
record.set('checkboxIsUnique',true);
record.raw[6] = true;
} else if(rowIdx == idx && checked===false){
record.set('checkboxIsUnique',false);
record.raw[6] = false;
}
record.commit();
});
}
}
},
{
text: 'Delete',
dataIndex: 'deleteColumn',
id: "deleteColumn"
}
],
listeners: {
},
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2
})
]
}
In the checkchange
listener
And this is simplified function that generates the store and renders the grid:
renderSchema: function() {
var grid = Ext.getCmp("schema");
for (var i = 0; i < myGridData; i++) {
storeArr[i][0] = myGridData[i].name;
storeArr[i][1] = myGridData[i].type;
storeArr[i][2] = myGridData[i].size;
storeArr[i][3] = i;
storeArr[i][4] = "<button class='schemaDeleteButton x-btn'> </button>";
storeArr[i][5] = myGridData[i].filteringType;
storeArr[i][6] = myGridData[i].isUnique; // true/false;
}
var dataStore = Ext.create('Ext.data.ArrayStore', {
extend: 'Ext.data.Model',
fields: [
{name: 'name'},
{name: 'type'},
{name: 'size'},
{name: 'position'},
{name: 'deleteColumn'},
{name: 'filteringType'},
{name: 'checkboxIsUnique'}
],
data: storeArr
});
grid.suspendEvents();
grid.reconfigure(dataStore);
grid.resumeEvents();
}
So I'm passing true or false for the field checkboxIsUnique
, but it doesn't affect my interface that looks like this:
Aucun commentaire:
Enregistrer un commentaire