2017-07-14 53 views
1

Doc of Descripter,也有在dataSourcessettings只有odataVersionlocalUriannotationsmaxAge,如果我想添加一個動態參數是什麼,如URL日期?如何在dataSources中添加動態參數?

如:

"dataSources": { 
    "mainService": { 
     "uri": "getData?Date=" + new Date(), 
     "type": "JSON" 
    } 
} 
+0

我認爲這是沒有可能的,從這個配置。你需要在URl的日期擺脫緩存的數據?如果將maxAge設置爲0,會有幫助嗎?用於緩存的 –

+0

您應該使用不同的機制。你想達到什麼目的? – Jorg

回答

0

我以前Aggregation Binding來解決這個問題:

 //worklist.controller.js 
     onInit : function(oEvent) {    
      const oView = this.getView(), 
      oModel = new sap.ui.model.json.JSONModel(), 
      oTable = oView.byId("table"); 

      oTable.setBusy(true); 

      oModel.loadData("getData?Date=" + new Date()); 
      oModel.attachRequestCompleted(function() { 
       oTable.setBusy(false); 
      }); 

      //Set a name for oModel so that it won't confused with my mainService 
      oView.setModel(oModel, "myModel");  
     }, 

     //worklist.view.xml 
     <Table 
      id="table" 
      items="{ 
       path: 'myModel>/' 
      }"> 
      <columns> 
       <Column><Text text="ID"/></Column> 
      </columns> 

      <items> 
       <ColumnListItem> 
        <cells> 
         <Text text="{myModel>ID}"/> 
        </cells> 
       </ColumnListItem> 
      </items> 
     </Table>