请大侠们帮忙看一下EXT中,从EditorGrid中删除行出总是报错

Jwens 2010-07-22 01:06:59
这是JS代码,里面没有Ext.onReady语句,在html页面中才装载,顺便说一上用到的数据都是在前台模拟,并没有与数据交互

Ext.QuickTips.init();
Fax.sm = new Ext.grid.CheckboxSelectionModel();
Fax.store.testFaxData = [{
"faxId" : "17",
"faxName" : "传真机A"
}, {
faxId : "17",
faxName : "传真机B"

}];
var reader = new Ext.data.JsonReader({}, [{
name : 'faxId'
}, {
name : 'faxName'
}])
Fax.store.faxStore = new Ext.data.Store({
proxy : new Ext.data.MemoryProxy(Fax.store.testFaxData),
reader : reader
});
var columnModel = new Ext.grid.ColumnModel([sm, {

header : "传真机ID",
width : 160,
sortable : true,
editor : new fm.TextField({
allowBlank : false
}),
dataIndex : 'faxId'
}, {
header : "传真机名称",
width : 160,
sortable : true,
editor : new fm.TextField({
allowBlank : false
}),
dataIndex : 'faxName'
}]);
var removeButton = Ext.form;
Fax.grid.FaxManagePanel = Ext.extend(Ext.grid.EditorGridPanel, {
cm : columnModel,
sm : Fax.sm,

store : Fax.store.faxStore,
closable : true,
stripeRows : true,

clicksToEdit : 1,

width : 300,
height : 300,
frame : true,
listeners : {
afteredit : function(e) {
e.record.commit()
}
}
});
Fax.ds_model = Ext.data.Record.create([

'faxId',

'faxName'

]);

Fax.store.faxStore.load();


这是html页面中的JS代码

else if("传真机管理"==title)
{
Ext.getCmp("contentBodyPanel").add(new Fax.grid.FaxManagePanel
(
{
closable:true,
title:title,
iconCls:'faxManage',
autoShow:true,
tbar:[
{pressed:true,text:'刷新',tooltip:'刷新传真机列表',iconCls:'refresh'},'-',
{pressed:true,text:'添加',tooltip:'添加传真机',iconCls:'resend',
handler: function()
{
Fax.store.faxStore.insert(0,new Fax.ds_model({
faxId:'id',
faxName:'传真机名称'
})
),
Fax.grid.FaxManagePanel.startEditing(0,0)

}

},'-',
{pressed:true,text:'删除',tooltip:'删除传真机',iconCls:'remove',
handler: function()
{
下面这名从EditorGridPanel中获得选中的行时就报错说无属性或方法
var sm = Fax.grid.FaxManagePanel.getSelectionModel(); var cell = sm.getSelectedCell();
var record = Fax.store.faxStore.getAt(cell[0]);
Fax.store.faxStore.remove(record);

}
}
]
}
)
).show();
}

...全文
228 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
liangakun 2010-07-26
  • 打赏
  • 举报
回复
弱弱的飘过
「已注销」 2010-07-23
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 zoujp_xyz 的回复:]
你不要再用Fax.grid.FaxManagePanel了 用myGrid
[/Quote]
现在把mygrid定义为全局变量,代码改成这样:

{pressed:true,text:'删除',tooltip:'删除传真机',iconCls:'remove',
handler: function()
{
var sm = mygrid.getSelectionModel();
document.write("+++++++++"+sm.getCount());//这可以输出所选记录数
var sel = sm.getSelected;
document.write(sel);
if (sm.hasSelection())
{
document.write("======="+mygrid.getStore().getCount());//这也可以输入store里面的所有记录,
mygrid.getStore.remove(sel)//但是这,当删除时就报错说没有该属性或方法

}

}

}
「已注销」 2010-07-23
  • 打赏
  • 举报
回复
哎,不用了,自己解决了,应该是这样:

{pressed:true,text:'删除',tooltip:'删除传真机',iconCls:'remove',
handler: function()
{
var sm = mygrid.getSelectionModel().getSelections();
for(var i = 0, r; r = sm[i]; i++){
Fax.store.faxStore.remove(r);
}
}

}

「已注销」 2010-07-23
  • 打赏
  • 举报
回复
再加10分,请求达人解答
zoujp_xyz 2010-07-22
  • 打赏
  • 举报
回复
你不要再用Fax.grid.FaxManagePanel了 用myGrid
「已注销」 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zoujp_xyz 的回复:]
JScript code

else if("传真机管理"==title)
{
Ext.getCmp("contentBodyPanel").add(new Fax.grid.FaxManagePanel //这句改改试试

Ext.getCmp("contentBodyPanel").add(var myGrid=new Fax.grid.Fax……
[/Quote]
直接就是语法错误呢,我用document.write(Fax.grid.FaxManagePanel),倒是可以输出这个function(){sp.apply(this,arguments)}是不是证明可以得到这个对象的,但还是那个错误:该对象没有些方法或属性
zoujp_xyz 2010-07-22
  • 打赏
  • 举报
回复
不行 把 myGrid设为全局的
zoujp_xyz 2010-07-22
  • 打赏
  • 举报
回复

else if("传真机管理"==title)
{
Ext.getCmp("contentBodyPanel").add(new Fax.grid.FaxManagePanel //这句改改试试

Ext.getCmp("contentBodyPanel").add(var myGrid=new Fax.grid.FaxManagePanel
+
var sm = myGrid.getSelectionModel();
var cell = sm.getSelectedCell();
var record = myGrid.getStore().getAt(cell[0]);
myGrid.getStore().remove(record);

「已注销」 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 ibm_hoojo 的回复:]
CSS code

你的ext显示后有checkbox选项么
Fax.sm = new Ext.grid.CheckboxSelectionModel();
不知道有没有成功赋给sm对象
Fax.grid.FaxManagePanel.getSelectionModel()
Fax.grid.FaxManagePanel这个是存在,可以取得这个对象么
[/Quote]
有checkbox选项的,但现在我也不知道可不可以取得Fax.grid.FaxManagePanel这个对象呢,因为这个对象是在JS文件里面申明,然后又在页面中new一个它的实例
hoojo 2010-07-22
  • 打赏
  • 举报
回复

你的ext显示后有checkbox选项么
Fax.sm = new Ext.grid.CheckboxSelectionModel();
不知道有没有成功赋给sm对象
Fax.grid.FaxManagePanel.getSelectionModel()
Fax.grid.FaxManagePanel这个是存在,可以取得这个对象么
「已注销」 2010-07-22
  • 打赏
  • 举报
回复
按照2楼的做了,还是Fax.grid.FaxManagePanel.getSelectionModel(); 这一行报错呢,对象无此属性或方法
hoojo 2010-07-22
  • 打赏
  • 举报
回复

var sm = Fax.grid.FaxManagePanel.getSelectionModel();
var cell = sm.getSelectedCell();
var record = Fax.store.faxStore.getAt(cell[0,0]);
Fax.store.faxStore.remove(record);

「已注销」 2010-07-22
  • 打赏
  • 举报
回复
自己先ding一下

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧