我有一个产生网格的 extjs 商店。在网格的第一列中,我有一个 rownumberer xtype 来生成序列号。
在网格中,我可以通过某些操作添加(从其他网格)或删除记录。添加时会从其他网格复制行号。我希望在每次添加或删除后对 rownumberer 进行排序。请帮助。
items: [
{
xtype: 'grid',
id: 'allSurveyGrid',
store: alludfStore,
border: false,
width: 600,
height: 250,
layout: 'fit',
columns: [{
xtype: 'rownumberer'
}, {
header: 'Date',
sortable: false,
dataIndex: 'createdDt',
flex: 0.3
}, {
header: 'Question Name',
sortable: false,
dataIndex: 'questiontext',
flex: 1
}
],
selModel: {
mode: 'MULTI'
},
}, {
xtype: 'tbspacer',
height: 10
}, {
xtype: 'container',
header: false,
style: {
left: '465px'
},
layout: {
type: 'hbox'
},
items: [{
xtype: 'tbspacer',
width: 250
}, {
xtype: 'button',
text: '▼',
id: 'selectQn',
//flex: 1,
height: 40,
width: 40,
handler: function () {
//Elison : Delegate this to controller once the function is ready.
var allSurveyGrid = Ext.getCmp("allSurveyGrid");
var selModels = allSurveyGrid.getView().getSelectionModel().getSelection();
var selSurveyGrid = Ext.getCmp("addSurveyGrid");
var selectedSurveyStore = selSurveyGrid.getStore();
var countOfQuestion = 0;
if (selModels.length == 0) {
Ext.Msg.alert(' ' + 'ERROR', "Select atleast one question to add.");
return;
}
for (var c = 0; c < selectedSurveyStore.data.length; c++) {
item = selectedSurveyStore.data.items[c].data;
if (item.qName !== null && item.qName !== "") {
countOfQuestion = countOfQuestion + 1;
} else {
selectedSurveyStore.remove(selectedSurveyStore.getAt(c));
}
}
var finalCount = countOfQuestion + (selModels.length);
if (finalCount >= 16) {
Ext.Msg.alert(' ' + 'ERROR', "More than 15 UDF is not allowed");
return;
} else {
// selectedSurveyStore.add(selModels);
/* for(var x=0;x<selModels.length;x++){
selModels.getAt[0].set('questionId',selectedSurveyStore.data.length+1);
}*/
selectedSurveyStore.loadData(selModels, true);
selSurveyGrid.getView().refresh();
}
}
}, {
xtype: 'tbspacer',
width: 10
}, {
xtype: 'button',
text: '▲',
id: 'unSelectQn',
height: 40,
width: 40,
style: {
borderRadius: 0
},
//flex: 1,
handler: function () {
var selSurveyGrid = Ext.getCmp("addSurveyGrid");
var selModels = selSurveyGrid.getView().getSelectionModel().getSelection();
var selectedSurveyStore = selSurveyGrid.getStore();
selectedSurveyStore.remove(selModels);
},
}, {
xtype: 'tbspacer',
width: 250
}
]
}, {
xtype: 'tbspacer',
height: 10
}, {
xtype: 'grid',
id: 'addSurveyGrid',
store: addudfStore,
border: false,
width: 600,
height: 250,
layout: 'fit',
columns: [{
xtype: 'rownumberer'
}, {
header: 'Date',
sortable: false,
dataIndex: 'createdDt',
flex: 0.3
}, {
header: 'Question Name',
sortable: false,
dataIndex: 'questiontext',
flex: 1
}
],
selModel: {
mode: 'MULTI'
},
viewConfig: {
plugins: {
ptype: 'gridviewdragdrop'
}
}
}
]