首先来一段GridPanel的定义:
var sm2 = new Ext.grid.CheckboxSelectionModel({});
/** 定义Grid2的数据源 */
var personStore = new Ext.data.JsonStore({
method : "POST",
fields : ["id","organizationName","holderBirth","holderName","basicCardno","holderTel"] //与Grid1列一致,至少列名称一致
});
var personColumn = new Ext.grid.ColumnModel([sm2, {
header : 'ID',
sortable : true,
hidden : true,
dataIndex : 'id'
}, {
header : 'organizationName',
sortable : true,
hidden : true,
dataIndex : 'organizationName'
}, {
header : '姓名',
sortable : true,
dataIndex : 'holderName'
}, {
header : '卡号',
sortable : true,
dataIndex : 'basicCardno'
}, {
header : '生日',
sortable : true,
dataIndex : 'holderBirth'
}, {
header : '电话',
sortable : true,
dataIndex : 'holderTel'
}]);
var personGrid = new Ext.grid.GridPanel({
region : 'center',
title : "出席会议的人员列表",
height : 200,
border : true,
store : personStore,
tbar: [btn_save, '-', btn_remove, '-', btn_check],
viewConfig : {
forceFit : true
},
cm: personColumn,
sm: sm2
});
比如personGrid中选择了多行,我们就来获取这选择的多行的详细信息:
/** 组织右侧personGrid中的数据,格式:[{id,name};{id,name}] */
var personStore = personGrid.getStore();
for(var i = 0; i < personStore.getCount(); ) {
var sublist = "";
/** 获取详细信息*****begin */
var holderName = personStore.getAt(i).get("holderName");
var holderBirth = personStore.getAt(i).get("holderBirth");
var basicCardno = personStore.getAt(i).get("basicCardno");
var holderTel = personStore.getAt(i).get("holderTel");
/** 获取详细信息*****begin */
sublist = "{holderName:" + holderName + ",holderBirth:" + holderBirth + ",basicCardno:" + basicCardno + ",holderTel:" + holderTel + "}";
if(i == personStore.getCount() -1) {
dataList = dataList + sublist;
}else{
dataList = dataList + sublist + ";";
}
i = i + 1;
}
dataList = dataList + "]";