是这样的一个问题,添加成功之后报this.store为空或不是对象,编辑成功之后也报这个问题,我不知道是什么问题?可以帮忙看看吗?代码贴出来给大家看看。var InspectDept=Ext.data.Record.create([
{name : 'ID',mapping : 'PK_INSPECTDEPT_ID',type : 'int'},
{name : 'attribute1', mapping : 'attribute1',type : 'string'},
{name : 'attribute2',mapping : 'attribute2',type : 'string'},
{name : 'attribute3',mapping : 'attribute3',type : 'string'},
{name : 'attribute4',mapping : 'attribute4',type : 'string'},
{name : 'attribute5',mapping : 'attribute5',type : 'string'},
{name : 'isEntrustDept',mapping : 'isEntrustDept',type : 'string'},
{name : 'createDate', mapping : 'createDate',type : 'string'},
{name : 'deptCode',mapping : 'deptCode',type : 'string'},
{name : 'deptName', mapping : 'deptName',type : 'string'},
{name : 'lastModifyBy',mapping : 'lastModifyBy',type : 'string'},
{name : 'lastModifyDate',mapping : 'lastModifyDate',type : 'string'},
{name : 're',mapping : 're',type : 'string'}
]);var ds_inspectDept = new Ext.data.Store({
url : 'showListInspectDept.action',
reader : new Ext.data.JsonReader(
{totalProperty : 'totalProperty',root : 'root'},
[
{name : 'ID',type : 'int'}, //编号
{name : 'deptCode',type : 'string'}, //编号
{name : 'deptName',type : 'string'}, //部门名称
{name : 'isEntrustDept',type : 'string'},//是否委托单位
{name : 're',type : 'string'}//备注
])
});
var record_start=0;
var sm_InspectDept=new Ext.grid.CheckboxSelectionModel();
var cm_inspectDept = new Ext.grid.ColumnModel([sm_InspectDept,
new Ext.grid.RowNumberer({
header : "序号",
width : 40,
renderer:function(value,metadata,record,rowIndex){
return record_start + 1 + rowIndex;
}
}),
{header : '编号',width : 40, dataIndex : 'deptCode',sortable : true},
{header : '部门名称',width : 50, dataIndex : 'deptName',sortable : true},
{header : '是否委托单位',width : 60,dataIndex : 'isEntrustDept',sortable : true},
{header : '备注', width : 90, dataIndex : 're',id : 're',sortable : true}]
); var btn_add_InspectDept = new Ext.Button({
text : '添加部门',
iconCls : 'icon-add',
handler : function() {
window_add_InspectDept.show();
}
});
var AddInspectDeptForm = new Ext.FormPanel({
url : 'saveInspectDept.action',
labelAlign : 'left',
labelWidth : 100,
bodyStyle : 'padding:5px',
border : false,
fileUpload : true,
baseCls : 'x-plain',
items : [{
layout : 'column',
border : false,
baseCls : 'x-plain',
items : [{
columnWidth : .5,
layout : 'form',
baseCls : 'x-plain',
border : false,
defaultType : 'textfield',
defaults : {anchor : '93%'},
items : [
{xtype : 'hidden',name : 'ID'},
{fieldLabel : '编 号 (*)',name : 'deptCode',maxLength : 25,allowBlank : false,emptyText:'请输入编号'},
{xtype : 'combo',name : 'isEntrustDept',fieldLabel : '是否委托单位(*)',
hiddenName:'isEntrustDept',valueField:'value',displayField:'text',
mode : 'local',
store:new Ext.data.SimpleStore({
data : [['是', '是'], ['否', '否']],
fields : ['text', 'value']
}),
selectOnFocus : true,editable : false,
allowBlank : false,triggerAction : 'all',loadingText : '加载中...',
listClass: 'x-combo-list-small',
renderer: Ext.util.Format.comboboxRenderer ,
emptyText : '请选择是否委托单位',
listeners :
{ // 获得下拉文本内容,解决id,value都要的情况
'select' : function(combo, record, index) {
//ds_dept2_select.reload();
///this.ownerCt.form.findField('parentDeptName').setValue(record.data.get('deptName'));
}
}
}]
}, {
columnWidth : .5,
layout : 'form',
border : false,
baseCls : 'x-plain',
defaultType : 'textfield',
defaults : {anchor : '93%'},
items : [
{fieldLabel : '部门名称(*)',name : 'deptName',maxLength : 25,allowBlank : false,emptyText:'请输入部门名称'}
]
}]
}, {
xtype : 'panel',
baseCls : 'x-plain',
bodyBorder : false,
layout : 'form',
defaultType : 'textarea',
defaults : {anchor:'95%'},
items : [
{fieldLabel : '备注',name : 're',maxLength : 500}
]
}],
buttonAlign : 'center',
minButtonWidth : 60,
buttons : [{
text : '添加',
handler : function(btn){
if (AddInspectDeptForm.getForm().isValid()) {
btn.disable();
var bnfield = AddInspectDeptForm.getForm().findField('deptCode');
AddInspectDeptForm.getForm().submit({
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_InspectDept.getStore();
if (store.data.length <= 20) {
var inspectDept = new InspectDept({
deptCode : form.findField('deptCode').getValue(),
deptName : form.findField('deptName').getValue(),
re : form.findField('re').getValue(),
isEntrustDept : form.findField('isEntrustDept').getValue()
});
store.insert(store.data.length, [inspectDept]);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
Ext.Msg.show({
title : '提示',
msg : '添加成功!!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
window_add_InspectDept.close();//窗体关闭
AddInspectDeptForm.getForm().reset();//重置窗体
btn.enable();//激活按钮
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg :'操作失败!!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
}
}
}, {
text : '重置',
handler : function() {this.ownerCt.form.reset();}
}, {
text : '取消',
handler : function() {this.ownerCt.ownerCt.hide();}
}]
});
{name : 'ID',mapping : 'PK_INSPECTDEPT_ID',type : 'int'},
{name : 'attribute1', mapping : 'attribute1',type : 'string'},
{name : 'attribute2',mapping : 'attribute2',type : 'string'},
{name : 'attribute3',mapping : 'attribute3',type : 'string'},
{name : 'attribute4',mapping : 'attribute4',type : 'string'},
{name : 'attribute5',mapping : 'attribute5',type : 'string'},
{name : 'isEntrustDept',mapping : 'isEntrustDept',type : 'string'},
{name : 'createDate', mapping : 'createDate',type : 'string'},
{name : 'deptCode',mapping : 'deptCode',type : 'string'},
{name : 'deptName', mapping : 'deptName',type : 'string'},
{name : 'lastModifyBy',mapping : 'lastModifyBy',type : 'string'},
{name : 'lastModifyDate',mapping : 'lastModifyDate',type : 'string'},
{name : 're',mapping : 're',type : 'string'}
]);var ds_inspectDept = new Ext.data.Store({
url : 'showListInspectDept.action',
reader : new Ext.data.JsonReader(
{totalProperty : 'totalProperty',root : 'root'},
[
{name : 'ID',type : 'int'}, //编号
{name : 'deptCode',type : 'string'}, //编号
{name : 'deptName',type : 'string'}, //部门名称
{name : 'isEntrustDept',type : 'string'},//是否委托单位
{name : 're',type : 'string'}//备注
])
});
var record_start=0;
var sm_InspectDept=new Ext.grid.CheckboxSelectionModel();
var cm_inspectDept = new Ext.grid.ColumnModel([sm_InspectDept,
new Ext.grid.RowNumberer({
header : "序号",
width : 40,
renderer:function(value,metadata,record,rowIndex){
return record_start + 1 + rowIndex;
}
}),
{header : '编号',width : 40, dataIndex : 'deptCode',sortable : true},
{header : '部门名称',width : 50, dataIndex : 'deptName',sortable : true},
{header : '是否委托单位',width : 60,dataIndex : 'isEntrustDept',sortable : true},
{header : '备注', width : 90, dataIndex : 're',id : 're',sortable : true}]
); var btn_add_InspectDept = new Ext.Button({
text : '添加部门',
iconCls : 'icon-add',
handler : function() {
window_add_InspectDept.show();
}
});
var AddInspectDeptForm = new Ext.FormPanel({
url : 'saveInspectDept.action',
labelAlign : 'left',
labelWidth : 100,
bodyStyle : 'padding:5px',
border : false,
fileUpload : true,
baseCls : 'x-plain',
items : [{
layout : 'column',
border : false,
baseCls : 'x-plain',
items : [{
columnWidth : .5,
layout : 'form',
baseCls : 'x-plain',
border : false,
defaultType : 'textfield',
defaults : {anchor : '93%'},
items : [
{xtype : 'hidden',name : 'ID'},
{fieldLabel : '编 号 (*)',name : 'deptCode',maxLength : 25,allowBlank : false,emptyText:'请输入编号'},
{xtype : 'combo',name : 'isEntrustDept',fieldLabel : '是否委托单位(*)',
hiddenName:'isEntrustDept',valueField:'value',displayField:'text',
mode : 'local',
store:new Ext.data.SimpleStore({
data : [['是', '是'], ['否', '否']],
fields : ['text', 'value']
}),
selectOnFocus : true,editable : false,
allowBlank : false,triggerAction : 'all',loadingText : '加载中...',
listClass: 'x-combo-list-small',
renderer: Ext.util.Format.comboboxRenderer ,
emptyText : '请选择是否委托单位',
listeners :
{ // 获得下拉文本内容,解决id,value都要的情况
'select' : function(combo, record, index) {
//ds_dept2_select.reload();
///this.ownerCt.form.findField('parentDeptName').setValue(record.data.get('deptName'));
}
}
}]
}, {
columnWidth : .5,
layout : 'form',
border : false,
baseCls : 'x-plain',
defaultType : 'textfield',
defaults : {anchor : '93%'},
items : [
{fieldLabel : '部门名称(*)',name : 'deptName',maxLength : 25,allowBlank : false,emptyText:'请输入部门名称'}
]
}]
}, {
xtype : 'panel',
baseCls : 'x-plain',
bodyBorder : false,
layout : 'form',
defaultType : 'textarea',
defaults : {anchor:'95%'},
items : [
{fieldLabel : '备注',name : 're',maxLength : 500}
]
}],
buttonAlign : 'center',
minButtonWidth : 60,
buttons : [{
text : '添加',
handler : function(btn){
if (AddInspectDeptForm.getForm().isValid()) {
btn.disable();
var bnfield = AddInspectDeptForm.getForm().findField('deptCode');
AddInspectDeptForm.getForm().submit({
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_InspectDept.getStore();
if (store.data.length <= 20) {
var inspectDept = new InspectDept({
deptCode : form.findField('deptCode').getValue(),
deptName : form.findField('deptName').getValue(),
re : form.findField('re').getValue(),
isEntrustDept : form.findField('isEntrustDept').getValue()
});
store.insert(store.data.length, [inspectDept]);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
Ext.Msg.show({
title : '提示',
msg : '添加成功!!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
window_add_InspectDept.close();//窗体关闭
AddInspectDeptForm.getForm().reset();//重置窗体
btn.enable();//激活按钮
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg :'操作失败!!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
}
}
}, {
text : '重置',
handler : function() {this.ownerCt.form.reset();}
}, {
text : '取消',
handler : function() {this.ownerCt.ownerCt.hide();}
}]
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货