以下红色代码是我后来加上去的。原来的代码运行正常,而往Grid中增加一列时,就报出this.ds.fields.get(C) is undefined (142 out of range 60)的奇怪错误。经过自己尝试之后,必须加上蓝色代码方可运行正常(Note:蓝色的两个dataIndex都必须加 ,其它方式我都尝试过了,不行啊)。
var cm = new Ext.grid.ColumnModel
([
new Ext.grid.RowNumberer(),
{
header: '申请编号', dataIndex: 'applicationNO', width: 106
}
,{
header: '项目名称', id: 'projectName',dataIndex: 'projectName',tooltip: '点击项目名称即可查阅申请书', renderer: function(value,metadata,record){
return "<a title='点击查看申请书' style='cursor:pointer;text-decoration: underline;color: #15428b;' onClick='" + "viewApplication_A(" + record.get('id') + ")'>" + value + "</a>";
}
}
,{
header: '计划类别', dataIndex: 'projectCateName', width: 150
}
,{
header: '管理领域', dataIndex: 'manageFieldsName', width: 72
}
,{
header: '单位名称', dataIndex: 'unitName', width: 150
}
,{
header: '负责人', dataIndex: 'principalName', width: 52
}
,{
header: '归口部门', dataIndex: 'administrator', width: 86
}
,{
header: '提交时间', dataIndex :'submitDate', width :70, renderer: Ext.util.Format.dateRenderer('Y-m-d')
}
,{
header: '附件', dataIndex: 'id' ,width: 40,fixed: true,align: 'center',renderer: function(value,metadata,record) {
return '<a style="cursor:pointer" οnclick="viewAttachment(\'' + record.get('applicationNO') + '\')"><img src="../../images/icoImage/view.gif"></a>';
}
}
,{
header: '操作',dataIndex: 'id' ,width: 66,fixed: true,align: 'center',renderer: function(value,metadata,record) {
return '<a style="cursor:pointer;text-decoration: underline;color:red;" οnclick="rebuildXMLContent(\'' + record.get('id') + '\')">重新生成</a>';
}
}
]);
cm.defaultSortable = true;
var store = new Ext.data.JsonStore(
{
url: '../admin/viewApplication_AByState.action',
totalProperty: 'recordCount',
storeId: 'store',
root: 'results',
fields: ['id','applicationNO','projectName','projectCateName','unitName',
'principalName','administrator','manageFieldsName',
{name :'submitDate', type :'date', dateFormat :'Y-m-dTH:i:s'}]
});