链接有啦。。就是 不知道如何把id的值加到链接上。。。。。id的值不知道如何的获得。。
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吗?
[code="java"]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;
}
}[/code]
上面来自官方api
其实就是写个renderer
参数value, metaData, record, rowIndex, colIndex, store
value这个单元格的值
record 通过这个record能获得这行的所有信息
这样 你啥都能获得了
下面是一个例子
[code="java"]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 = "
例子代码来自:[url]http://damoqiongqiu.iteye.com/blog/422202[/url]
那估计你的grid的数据没有id
正常有的话 就不会报错
把你完整的grid的代码贴出看看