将gridpanel中store的一行数据填充到formpanel对应的组件
程序员文章站
2022-05-13 14:40:15
...
如题,tabpanel有两个tab子项,左边放gridpanel,右边放formpanel,当选中gridpanel的某一行,然后点击formpanel的tab,该行数据填充到formpanel中相对应的组件中,代码如下
GW.StudentInfoImportModule.DataTabPanel = Ext.extend(Ext.TabPanel,{
constructor : function (config){
Ext.apply(this,config);
GW.StudentInfoImportModule.DataTabPanel.superclass.constructor.call(this,{
region : 'center',
border : false,
activeItem : 0,
minTabWidth: 100,
tabWidth: 120,
items : [new GW.StudentInfoImportModule.ImportedData({
title:'导入的数据',iconCls:'module-edit-icon',border:false
}),
new GW.StudentInfoImportModule.SingleStudentData({
title:'出错的数据',iconCls:'module-edit-icon',border:false,
listeners:{
activate:function (tab){
//第一步先获得gridpanel里面选中的列,第二步获得该列的数据,第三步获得formpanel,第四步加载
var studentInfo = Ext.getCmp('studentInfoImportedData');
if(studentInfo.getSelectionModel().getSelected()){
var jsonData = studentInfo.getSelectionModel().getSelected().json;
var studentForm = Ext.getCmp('singleStudentBaseInfoFormPanel').getForm();
for(var name in jsonData){
setData(studentForm,jsonData,name);
}
}
}
}
})
]
});
}
});
setData = function (studentForm,jsonData,name){
if(studentForm.findField(name)){
studentForm.findField(name).setValue(jsonData[name]);
}
};
GW.StudentInfoImportModule.DataTabPanel = Ext.extend(Ext.TabPanel,{
constructor : function (config){
Ext.apply(this,config);
GW.StudentInfoImportModule.DataTabPanel.superclass.constructor.call(this,{
region : 'center',
border : false,
activeItem : 0,
minTabWidth: 100,
tabWidth: 120,
items : [new GW.StudentInfoImportModule.ImportedData({
title:'导入的数据',iconCls:'module-edit-icon',border:false
}),
new GW.StudentInfoImportModule.SingleStudentData({
title:'出错的数据',iconCls:'module-edit-icon',border:false,
listeners:{
activate:function (tab){
//第一步先获得gridpanel里面选中的列,第二步获得该列的数据,第三步获得formpanel,第四步加载
var studentInfo = Ext.getCmp('studentInfoImportedData');
if(studentInfo.getSelectionModel().getSelected()){
var jsonData = studentInfo.getSelectionModel().getSelected().json;
var studentForm = Ext.getCmp('singleStudentBaseInfoFormPanel').getForm();
for(var name in jsonData){
setData(studentForm,jsonData,name);
}
}
}
}
})
]
});
}
});
setData = function (studentForm,jsonData,name){
if(studentForm.findField(name)){
studentForm.findField(name).setValue(jsonData[name]);
}
};
下一篇: 求教php基础有关问题