mirinda95925 2009-11-19 14:43
浏览 244
已采纳

ExtJS选中记录赋值的问题

/*

  • My test
  • */ MyDesktop.GridWindow1 = Ext.extend(Ext.app.Module, { id:'grid-win1', init : function(){ this.launcher = { text: '我的测试,嘿嘿', iconCls:'icon-grid', handler : this.createWindow, scope: this } },

createWindow : function(){
/*

  • 对生成的表格进行扩展
  • */ var ds = new Ext.data.JsonStore({ remoteSort:true, url:'/newDesktop/fixinfo/getAll', fields:[ 'a','b','c','d','e', 'f','hhh','ggg' ], baseParams:{ limit:10 } }); ds.load({ params:{start:0} }); //end

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条回答 默认 最新

  • xkuff 2009-11-20 09:04
    关注

    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);

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP