var cm = new Ext.grid.ColumnModel ([ sm,new Ext.grid.RowNumberer({header:"编号",width:50}), {header:"编号",dataIndex:"ID",width:10,hidden:true}, {header:"标题",dataIndex:"TypeCName",width:100,editor:new Ext.form.TextField()}, {header:"英文名称",dataIndex:"TypeEName",width:100,editor:new Ext.form.TextField()}, {header:"状态",dataIndex:"DelFlag",width:100,renderer:function(value){if(value==false) {return "显示";} else {return "隐藏";}}}, {header:"添加日期",dataIndex:"AddDate",width:100,renderer:Ext.util.Format.dateRenderer('Y年m月d日')} ]); cm.defaultSortable = true; var fields = [ {name:"ID"}, {name:"TypeCName"}, {name:"TypeEName"}, {name:"DelFlag"}, {name:"AddDate"} ]; var store = new Ext.data.Store ({ proxy:new Ext.data.HttpProxy({url:url}), reader:new Ext.data.JsonReader({totalProperty:"totalPorperty",root:"root",fields:fields}) }); store.load({params:{start:0,limit:15}});
buttons: [ { xtype:"button",text:"确定提交",cls:"x-btn-text-icon",icon:"images/add.gif", handler:function() { //这里获取添加表单的数据 var typeCName = Ext.getCmp("TypeCName").getValue(); var typeEName = Ext.getCmp("TypeEName").getValue(); var addDate = Ext.getCmp("AddDate").getValue(); var delFlag = Ext.getCmp("DelFlag").getValue(); //同时可以对上面获取的数据添加验证 Ext.Ajax.request ({ http://www.cnblogs.com/mogen_yin/admin/%22jsonGrid.aspx?Param=add",//添加 url 具体在哪个页面实现添加功能 params:{ParamName:"good",TypeCNameParam:typeCName},//客户端页面向服务器断传递数据,前面是参数名称,后面是参数值,多个参数用逗号分隔开 success:function(respose,option) { //如果在服务器端正确处理了数据并且返回了正确的值得就执行该函数的语句 //将服务器端正确返回的json字符串转换横Ext对象,然后就能够使用 var result = Ext.util.JSON.decode(respose.responseText); //当确定添加成功后再执行下面的语句,动态加载数据列表 Ext.getCmp("MenuGridPanel").store.reload(); }, failure:function() { //如果在服务器端处理数据发生了异常,就执行该函数的语句 } }); } },