如何在dataSources中添加动态参数?

时间:2017-07-14 07:17:32

标签: sapui5

Doc of Descripter中,odataVersion的{​​{1}}中只有localUriannotationsmaxAgesettings,如果我想在url中添加Date等动态参数?

如:

dataSources

1 个答案:

答案 0 :(得分: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>