asp.net
extjs4mvc增删改查-凯发ag旗舰厅登录网址下载
ext.onready(function() {var csm = new ext.grid.checkboxselectionmodel({//创建checkbox对象
handlemousedown: newext.emptyfn()
});var cum = newext.grid.columnmodel([
csm,//checkbox对象
{header: "用户id", dataindex: "id", sortable: true},
{ header:'用户姓名', dataindex: 'name', sortable: true,
editor:newext.grid.grideditor(new ext.form.textfield({ allowblank: false}))
},
{ header:'性别', dataindex: 'sex', sortable: true,
editor:newext.grid.grideditor(new ext.form.textfield({ allowblank: false}))
}
]);
;var store = newext.data.store({
proxy:new ext.data.httpproxy({ url: 'userdata.aspx'}),
reader:newext.data.jsonreader({
totalproperty:'totalcount', //json字符串中的字段,数据量大小
root: 'data'//json字符串中的字段
}, [
{ name:'id'},
{ name:'name'},
{ name:'sex'}
]),
remotesort:true});var record =ext.data.record.create([
{ name:'id', type: 'string'},
{ name:'name', type: 'string'},
{ name:'sex', type: 'string'}
]);
store.load({ params: { start:0, limit: 5} }); //运行加载表格数据
var cumgrid = newext.grid.editorgridpanel({
renderto:'cumgrid',
store: store,
striperows:true, //斑马线效果
viewconfig: {
forcefit:true,
columnstext:"显示的列",
sortasctext:"升序",
sortdesctext:"降序"},
height:200,
width:550,
sm: csm,
bbar:newext.pagingtoolbar({
pagesize:5, //每页信息条数
store: store,
autowidth:true,
autoheight:true,
displayinfo:true,
prevtext:"上一页",
nexttext:"下一页",
refreshtext:"刷新",
lasttext:"最后页",
firsttext:"第一页",
beforepagetext:"当前页",
afterpagetext:"共{0}页",
displaymsg:'显示第{0}条到第{1}条记录,一共{2}条',
emptymsg:'没有记录'}),
tbar:new ext.toolbar(['-', {
text:'添加一行',
handler:function() {var win = newext.window({
title:'添加用户',
layout:'fit',
height:300,
width:300,
border:0,
frame:true, //去除窗体的panel框架
plain: true,
html:''});
win.show();//显示窗口
}
},'-', {
text:'删除一行',
handler:function() {
ext.msg.confirm('信息', '确定要删除?', function(btn) {if (btn = 'yes') {var id = "";functiongetid() {for (var i = 0; i < cumgrid.getselectionmodel().getselections().length; i ) {
id = cumgrid.getselectionmodel().getselections()[i].get("id");
id = ',';
}
};
getid();//初始化选中行id字符串数组
ext.ajax.request({
url:"deluserinfo.aspx",
method:"post",
params: { id: id },
success:function(response) {
ext.msg.alert("恭喜", "删除成功了!");
store.reload();
},
failure:function() {
ext.msg.alert("提 示", "删除失败了!");
}
})
}
});
}
},'-', {
text:'保存',
handler:function() {var m = store.getmodifiedrecords().slice(0);var jsonarray =[];
ext.each(m,function(item) {
jsonarray.push(item.data);
})if (false) {//判断条件
return;
}else{//alert(ext.encode(jsonarray))
ext.ajax.request({//url: "demo/operator.aspx",
url: "saveuserinfo.aspx",
method:"post",
params:'data=' encodeuricomponent(ext.encode(jsonarray)),
success:function(response, option) {
store.reload();
alert(response.responsetext);
},
failure:function(response) {
store.reload();
alert(response.responsetext)
ext.msg.alert("提示", "修改失败了!");
}
});
}
}
},'-']),
cm: cum
});
cumgrid.render();//刷新表格
});
与50位技术专家面对面20年技术见证,附赠技术全景图总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的extjs4mvc增删改查_asp.net下利用mvc模式实现extjs表格增删改查的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇:
- 下一篇: