data-bindingodatasapui5input-parameters

SAPUI5 odata bind table with input parameters in controller


I need to pass dynamic valued input parameter to calculation view via Odata binding to grid table. I can get calculation view result from Odata with following syntax:

...odata/SERVICE.xsodata/DataSetParameters(P_END_DATE=datetime'2013/07/10',P_START_DATE=datetime'2013/07/03')/Results?$format=json

I am binding grid table with following code in controller (date will be dynamic in actual application)

var gridTable = _this.getView().byId(gridName);
gridTable.setModel(oModel);
gridTable.bindRows("DataSet(P_END_DATE=datetime\'2013/07/10\',P_START_DATE=datetime\'2013/07/03\')", null, null, aFilters);

In runtime I am getting following errors

No key property 'P_END_DATE' exists in type...No key property 'P_END_DATE' exists in type ...Collection 'DataSet' is not directly accessible....Collection 'DataSet' is not directly accessible.

Can anyone help me to know what is the correct syntax to pass the parameter from odata binding?


Solution

  • The ODATA collection you expose will be available at /Results and is not directly accessible with /DataSet.

    A NavigationProperty is required to retrieve the results from the parameterized call. So you will have to change your binding path to this

    DataSetParameters(param1=value,param2=value)/Results
    

    Controller code gridTable.bindRows("DataSetParameters(P_END_DATE=datetime\'2013/07/10\',P_START_DATE=datetime\'2013/07/03\')/Results", null, null, aFilters);