遇到this.fields is undefind问题,纠结一下午。在晚上的时候终于找到原因所在
原数据源是这样写的
RestDataSource.create({
ID:"demoData",
dataFormat:"json",
fields: [
{name: "id",title:"id"},
...
{name:"button",title:"操作"}
],
fetchDataURL:"demo_fetch.do"
});
原listGrid
ListGrid.create({
ID:"tab_dbsq_list",
autoDraw: false,
selectionAppearance:"checkbox",
autoFetchData:false,
showRowNumbers:true,
dataPageSize:20,
showRecordComponents: true,
showRecordComponentsByCell: true,
dataSource: NeedPackageVisa,
warnOnRemoval:true,
warnOnRemovalMessage:"确定删除此条记录吗?",
createRecordComponent:function(record,colNum) {
var fieldName = this.getFieldName(colNum);
if (fieldName == "Button") {
var button = isc.IButton.create({
width: 30,
title: "",
icon: "[SKIN]/actions/remove.png",
click : function () {
//to do
}
});
return button;
}
}
});
list改为如下形式,并将dataSource中的fields删除,ok,问题解决。
ListGrid.create({
ID:"tab_dbsq_list",
autoDraw: false,
selectionAppearance:"checkbox",
autoFetchData:false,
showRowNumbers:true,
dataPageSize:20,
showRecordComponents: true,
showRecordComponentsByCell: true,
dataSource: NeedPackageVisa,
warnOnRemoval:true,
warnOnRemovalMessage:"确定删除此条记录吗?",
fields: [
{name: "id",title:"id"},
...
{name:"button",title:"操作"}
],
createRecordComponent:function(record,colNum) {
var fieldName = this.getFieldName(colNum);
if (fieldName == "Button") {
var button = isc.IButton.create({
width: 30,
title: "",
icon: "[SKIN]/actions/remove.png",
click : function () {
// to do
}
});
return button;
}
}
});