Skip to Content

[SAPUI5] Refresh table data using query Parameters and bind JSON data

Hi Experts,

I am using REST APIs to fetch data from backend, I want to fetch data based on query parameters.

My REST service does not return any data if there is no query parameter.

e.g My service URL is https://Host/rest/countries?region=asia

It will give list of countries if I give region=asia but if I don't add region then I will not get any country. I have defined service URL in menifest.json as below

"dataSources": { "mainService":{ "uri": "https://Host/rest/countries?region=", "type": "JSON" } },

Now I want to pass region value as parameter from input field and populate table.

If I give complete URL in manifest.json then my table is loaded on initial load

"dataSources": { "mainService":{ "uri": "https://Host/rest/countries?region=asia", "type": "JSON" } },

For me it's fine if initial load is blank but I want to load table after I pass parameter from input field.

How can be this achieved, any pointer will be helpful.

Regards,

Rohit

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 08, 2017 at 10:01 PM

    you will need to create a json model in your app and load the data async.

    here is an example of how the json model makes an ajax call

    https://sapui5.hana.ondemand.com/#/api/sap.ui.model.json.JSONModel -- look into loadData function

    Add comment
    10|10000 characters needed characters exceeded