问题描述
链接有啦。。就是 不知道如何把id的值加到链接上。。。。。id的值不知道如何的获得。。 问题补充:record.get('id') 报错。。。为undefiend.
解决方案
var reader = new Ext.data.JsonReader({ totalProperty: 'count', root: 'rows', id:"id",//The property within each row object that provides an ID for the record (可选) fields:[ {name: 'id',mapping:"id"}, {name: 'name',mapping:"name"}, {name: 'descn',mapping:"descn"} ]})比方上面的fields里面 你有name是id吗?
解决方案二:
那估计你的grid的数据没有id正常有的话 就不会报错把你完整的grid的代码贴出看看
解决方案三:
下面是一个例子var cm=new Ext.grid.ColumnModel([ sm, rowNum, {header: "姓名", dataIndex:'name',width: 100, sortable: true}, {header: "年龄", dataIndex:'age',width: 50, sortable: true}, {header: "工作", dataIndex:'work',width: 150, sortable: true}, {header: "公司", dataIndex:'company',width: 100, sortable: true}, {header: "所属行业", dataIndex:'industry',width: 80, sortable: true}, {header: "群", dataIndex:'QQ',width:150, sortable: true}, {header: "操作", dataIndex:'id',width:150, sortable: true,renderer:function(value,meta,record){ var resultStr = "<div class='controlBtn'>" + "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'>详细</a> & nbsp;" + "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'>删除</a> & nbsp;" + "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'>图表</a> & nbsp;" + "<a href='javascript:void("+record.get('id')+");' class='alarm_detail'>曲线</a> & nbsp;" + "</div>"; return resultStr; } } ]); 例子代码来自:http://damoqiongqiu.iteye.com/blog/422202
解决方案四:
var companyColumn = { header: 'Company Name', dataIndex: 'company', renderer: function(value, metaData, record, rowIndex, colIndex, store) { // provide the logic depending on business rules // name of your own choosing to manipulate the cell depending upon // the data in the underlying Record object. if (value == 'whatever') { //metaData.css : String : A CSS class name to add to the TD element of the cell. //metaData.attr : String : An html attribute definition string to apply to // the data container element within the table // cell (e.g. 'style="color:red;"'). metaData.css = 'name-of-css-class-you-will-define'; } return value; }}上面来自官方api 其实就是写个renderer 参数value, metaData, record, rowIndex, colIndex, storevalue这个单元格的值 record 通过这个record能获得这行的所有信息 这样 你啥都能获得了