/*
createWindow : function(){
/*
var thisGrid = new Ext.grid.GridPanel({
border:false,
store:ds,
columns:[
{header:'设备编号',dataIndex:'a',width:100,sortable:true},
{header:'设备名称',dataIndex:'b',width:100},
{header:'型号规格',dataIndex:'c',width:100},
{header:'区域',dataIndex:'d',width:80},
{header:'设备类型',dataIndex:'e',width:100},
{header:'生产国别',dataIndex:'f',width:100},
{header:'生产厂家',dataIndex:'hhh',width:100},
{header:'出厂编号',dataIndex:'ggg',width:100}
],
viewConfig: {
forceFit:true
},
//autoExpandColumn:'company',
bbar:new Ext.PagingToolbar({
store:ds,
pageSize:10,
displayinfo:'true',
displayMsg:'显示第{0}条记录到第{1}条记录,一共{2}条',
emptyMsg:'没有记录'
}),
tbar:[{
text:'增加设备',
tooltip:'点击这里来增加设备',
iconCls:'add',
handler:this.createUser.createDelegate(this)
}, '-', {
text:'修改设备',
tooltip:'选定一条记录后进行修改',
iconCls:'option',
handler:this.EditUser.createDelegate(this)
},'-',{
text:'删除设备',
tooltip:'选定一条设备之后进行删除',
iconCls:'remove'
}]
})
var desktop = this.app.getDesktop();
var win = desktop.getWindow('grid-win1');
if(!win){
win = desktop.createWindow({
id: 'grid-win1',
title:'我的测试',
width:740,
height:480,
iconCls: 'icon-grid',
shim:false,
animCollapse:false,
constrainHeader:true,
layout: 'fit',
items:thisGrid
});
}
win.show();
},
createUser:function(){
this.fixInfoWindow = new FixInfoWindow({
grid:this
});
this.fixInfoWindow.show();
//this.FixInfoWindow.setTitle('新建用户资料');
//this.FixInfoWindow.url = 'user/save'; //此处的url对应着UserController的save()方法
//this.FixInfoWindow.fp.form.reset();
},
EditUser:function(){
var rec =thisGrid.getSelectionModel().getSelected();
alert(rec)
if(rec){
this.fixInfoWindow = new FixInfoWindow({
grid:this
});
this.fixInfoWindow.show();
this.fixInfoWindow.fp.form.loadRecord(rec);
}
else{Ext.Msg.alert("出错了","请选择一条记录操作"); }
}
});
1.你的代码里好像没有定义Ext.grid.CheckboxSelectionModel
2.把EditUser函数中的代码改成:
var grid = Ext.getCmp('grid id');
if (grid == null) {
return;
}
var sm = grid.getSelectionModel();
if (sm == null) {
return;
}
var selections = sm.getSelections();
if (selections == null) {
return;
}
if (selections.length > 0) {
var record = selections[0];
if (record == null) {
return;
}
}
Ext.getCmp('form id').getForm().loadRecord(rec);