遇到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;
}
}
});