SmartClient--this.fields is undefind問題

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章