0

我想用下面的数组变量填充列表数据我已经设置了这个数组来存储这里是数组内的记录类型列表

   var logbookEntryList = [];

  var aircraftMxLog = new AircraftMxLog(); //domian 

    aircraftMxLog.mxlogIdNum = mxLogIdNum;
    aircraftMxLog.entryDatetime = entryDatetime;
    aircraftMxLog.recordName = recordName;
    aircraftMxLog.recordSourceId = recordSourceId;

     logbookEntryList.push(aircraftMxLog);


   var mxRelease = new MxRelease();
   mxRelease.mxReleaseTypeId = mxReleaseTypeId;
    mxRelease.entryDatetime = entryDatetime;
    mxRelease.comments = comments;
    mxRelease.firstName = firstName;
    mxRelease.lastName = lastName;

     logbookEntryList.push(mxRelease);

    var flightLog = new FlightLog();
    flightLog.flightNumId = flightNumId;
    flightLog.arvStationId = arvStationId;
    flightLog.deptStationId = deptStationId;
    flightLog.outDate = outDate;
    flightLog.offDate = offDate;

    logbookEntryList.push(flightLog);

所以像这样我将在我的数组中有不同类型的数据所以我如何将它映射到我的模型以填充到列表视图中

我已经尝试通过每个函数迭代存储,我能够在迭代中获取每个元素对象,但是在动态迭代到列表时无法设置 itemtpl

这是代码

       createViewFactory :function(){
      var manageAmlStore=Ext.getStore('ManageAMLStore');
      manageAmlStore.setData(logbookEntryList);
     // this.getManageAmlStore().setData(logbookEntryList);
      //
        console.log('manage Aml store size '+manageAmlStore.getCount());
      var manageAmlList=Ext.getCmp('manageAMlList')
        manageAmlStore.each(function(item, index, length){
        //console.info(item,length,index);
        console.log('item '+item+' index '+index+' length '+length)
        console.log('item size '+item.length)
        if(logbookEntryList[index] instanceof AircraftMxLog){
            manageAmlList.setItemTpl('AircraftMxLog'+index);
         } else if(logbookEntryList[index] instanceof MxRelease){
            manageAmlList.setItemTpl('MxRelease'+index);
            // manageAmlList.initComponent();
              //manageAmlList.render();
         }else if(logbookEntryList[index] instanceof  FlightLog){
            manageAmlList.setItemTpl('FlightLog'+index);
          }else if(logbookEntryList[index] instanceof  MxAction){
            manageAmlList.setItemTpl('MxAction'+index);
         }
        //Ext.getCmp('manageAMlList').setItemTpl('test'+id)
         //this.getManageAmlList().setItemTpl('test'+id);
       });
      manageAmlList.bindStore(manageAmlStore);

     }
4

1 回答 1

0

您的系统的问题是您发送的是字符串而不是变量

'MxRelease' + index 是一个字符串,而不是您之前声明的变量。

要执行类似的操作,您必须以这种方式创建一个对象

TEMPLATe = 
{    tplvar = 
     {
      mxrelease2 : 'your template',
     },
    'MxRelease2' : function(tplvar){return tplvar.mxrelease2;},
}

如果我没记错的话,它被称为字典(javascript)

于 2013-08-06T15:21:08.577 回答