1、拼装按钮
备注:行标识id,在加载显示的时候就已和按钮绑定到一起,并相应的执行按钮操作;
/*表格数据源*/ var store = new Ext.data.Store({ proxy:new Ext.data.HttpProxy({url:'TestAction!testMethod.action'}), reader:new Ext.data.JsonReader({ totalProperty:'total', root:'result' }, [ {name:'planedId'}, /*安检计划唯一编号*/ {name:'symbol'}, /*编号*/ {name:'smbDesc'}, /*地址*/ {name:'planedCnt'}, /*户数*/ {name:'checkDatePlan'}, /*计划日期*/ {name:'checkUnit'}, /*安检单位*/ {name:'printTime'}, /*打印时间*/ {name:'cancel'} /*取消计划*/ ]), sortInfo:{field:'symbol',direction:'DESC'} /*排序*/ }); /*列模型中渲染的按钮*/ var cancelRender = function cancel(value){ cancelButton='
'; cancelButton+=' | '; cancelButton+=' |
2、返回图片按钮链接
备注:行标识id,在图片按钮显示过后,当执行按钮事件时,在函数中通过循环选择模型来获取,并相应的执行按钮操作;
对于这个例子,我就不做太多赘述,简单最好。代码中唯一改动的就是,按钮显示的方式改变了。好了,我来写一下。
对于store的加载,省略。来说列模型中按钮的显示
Ext.namespace("MCGM"); /*MCGM为命名空间*/ MCGM.cm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), {header:'客户编号',width:150,dataIndex:'customerId'}, {header:'客户名称',width:150,dataIndex:'name'}, {header:'地址', width:150,dataIndex:'address'}, {header:'组别', width:150,dataIndex:'group0'}, {header:'顺序', width:150,dataIndex:'order0'}, {header:'调整', width:150,,dataIndex:""menuDisabled:true, renderer:function(v){ return ""; } } ]); MCGM.grid = new Ext.grid.GridPanel({ cm:MCGM.cm, store:MCGM.store, loadMask: {msg:'正在加载中,请稍后..'}, //加载时显示的等待信息 sm:new Ext.grid.RowSelectionModel({singleSelect:true}), viewConfig:{forceFit:true,autoScroll:true}, }); /*下面是我做的一个调整功能,需要跳到另外一个新页面,并要获得行的所有值,特别是行标识id,这里我就只把获得行信息的代码写出来,不怎么难,就几行,还是写一下吧!*/ var update = function(){ Ext.Msg.confirm("提示框","您确定要调整此项记录吗?",function(btn){ if(btn == 'yes'){ /*关键代码*/ MCGM.view = MCGM.grid.getView(); MCGM.rsm = MCGM.grid.getSelectionModel(); MCGM.store = MCGM.grid.getStore(); for(var i = MCGM.view.getRows().length-1;i>=0;i--){ if(MCGM.rsm.isSelected(i)){ var customerId = MCGM.grid.getStore().getAt(i).get('customerId'); var name = MCGM.grid.getStore().getAt(i).get('name'); var address = MCGM.grid.getStore().getAt(i).get('address'); var group0 = MCGM.grid.getStore().getAt(i).get('group0'); var order0 = MCGM.grid.getStore().getAt(i).get('order0'); } } } }); };
author:xiesj@date:2010.10.27 16:12@blog: http://blog.csdn.net/xieshengjun2009