PDA

View Full Version : gridselect count is not correct



michaelc
2 Nov 2009, 5:48 PM
I have a sub function that is being passed an array, the display is correct, but when I click the ok button, the selection count is incorrect. it shows the max count every time even when only one or two chcekboxs were set.

any idea on what I have missed ?



function createWindowPublish(passArray, type) {

var jobStore = new Ext.data.SimpleStore( {
fields : [
{ name : 'jobFileName'},
{ name : 'status', },
{ name : 'type' }
],
data: passArray
});

// jobStore.loadData(passArray);

var smcPublish = new Ext.grid.CheckboxSelectionModel();

var jobGrid = new Ext.grid.GridPanel( {
store :jobStore,
id : "EAdminFileManager-publish-grid",
loadMask: true,
cm :new Ext.grid.ColumnModel( [ smcPublish, {
header :type,
width :290,
sortable :true,
dataIndex :'jobFileName',
renderer : function(v, p) {
// v : value , p : cell
p.attr = 'ext:qtitle="' + v + '"';
p.attr += ' ext:qtip=" "';
return v;
}
} ]),
sm :smcPublish,
width :290,
autoHeight :true,
iconCls :'icon-grid',
listeners : {
render : function(c) {
smcPublish.selectAll();
}
}
});


resp_win = new Ext.Window( {
title :pubTitle1 + type + pubTitle2,
width :300,
autoHeight :true,
id : "EAdminFileManager-publish-win",
modal :true,
items : [ {
layout :'anchor',
hideBorders :true,
items : [ {
border :0,
items :jobGrid
},{
layout:"column",
items:[{
columnWidth:0.5,
items:[{
xtype:"checkbox",
boxLabel:box1Label,
name:"checkbox1",
hidden : box1Hide,
id : "EAdminFileManager-publish-template"
}]
},{
columnWidth:0.5,
items:[{
xtype:"checkbox",
boxLabel:box2Label,
name:"checkbox2",
hidden : box2Hide,
id : "EAdminFileManager-publish-inclusive"
}]
}]
} ],
buttonAlign :'left',
buttons : [ {
text :okLit,
id :'EAdminFileManager-publish-respbuttonOk',
listeners : {
click : function(c) {
var requestGrid = Ext.getCmp("EAdminFileManager-publish-grid");
var count = requestGrid.selModel.getCount();
var recordArray = requestGrid.selModel.getSelections();
if (requestGrid.selModel.getCount() == 0){
Util.showMessage('You must select at least one item to publish');
}


}
}

}, {
text :cancelLit,
id :'EAdminFileManager-publish-respbuttonCancel',
listeners : {
click : function(c) {
resp_win.close();
}
}
} ]
} ]
});

resp_win.show();

}