Skip to Content

Issue displaying odata in SAPUI5 Smart Table

Hi Guys,

I am trying to use the Smart Table control instead of sap.m.table in my project. On following the reference in SAPUI5 Explored I used the Filter and Table code.

The below code was used in my controller instead of loading data from the mock server.

I am able to get the sorter and filters but my Smart Table shows "No Data".

The errors I get on performing the filter operation are

1. Error: resource smarttableSmartTable/Component-changes.json could not be loaded from ./Component-changes.json. Check for 'file not found' or parse errors. Reason: Not Found -

2. 'getChanges' failed: -

Please provide suggestions as to where I could have gone wrong.

Thanks,

Srinivasan

jQuery.sap.require("sap.ui.core.util.MockServer");
var oModel;
var oMockServer = new sap.ui.core.util.MockServer({
rootUri: "/sap/opu/odata/SAP/ZCFS_CUSTOMER_LIST_SRV/"
});
this._oMockServer = oMockServer;
oMockServer.simulate("localService/ZCFS_CUSTOMER_LIST_SRV/metadata.xml", "localServiceZCFS_CUSTOMER_LIST_SRV");
oMockServer.start();
oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/SAP/ZCFS_CUSTOMER_LIST_SRV/", true);
oModel.setCountSupported(false);
var oView = this.getView();
oView.setModel(oModel);
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Feb 10, 2017 at 04:16 PM

    Add the following parameter to your smart table:

    initiallyVisibleFields="Kunnr1,Name1"
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 15, 2017 at 05:08 PM

    Hi Srenivasan,

    There are 2 ways to get the default columns to smart table.

    First it looks for metadata for below annotation, if this not defined you have option to provide via smart table property as Radek mentioned. initiallyVisibleFields="Kunnr1,Name1"

    <Annotation Term=”com.sap.vocabularies.UI.v1.LineItem”>

    Then table is formed is rendered with columns with either of the above options.

    Once table is rendered the binding is triggered with the entityset you have provided and this will be a request to server with url as below

    /sap/opu/odata/SAP/ZCFS_CUSTOMER_LIST_SRV/ZCFS_CustSet?

    see if this returns data!!

    If not you might have some default filters to pass to fetch data which can be handled in onBeforeBinding event of smart table.

    onBeforeRebindTable: function(oEvent) {
    var mBindingParams = oEvent.getParameter("bindingParams");
    var aFilter = [];
    if (<if filter has value>) {
    aFilter.push(new sap.ui.model.Filter("<fieldname>", sap.ui.model.FilterOperator.EQ, "<filtervalue>"));
    mBindingParams.filters = aFilter;
    }
    },

    you can also click on go button to get the data if service url above works to get data, you can fire the request from browser to see what is the response.

    Regards,

    BG

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 09, 2017 at 03:47 PM

    Hello Srinivasan,

    The above error you get can be ignored . This is a general that call that UI5 framework makes to check for certain files . Absence of this will not hurt the application. What i am interested in seeing is the Smart table binding. Can you share that. I am pretty sure that is where the issue is.

    Thanks and Regards,

    Veera

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 10, 2017 at 08:38 AM

    Hi Srinivasan,

    In order to use mock server the data must be available with in the the app itself .

    Please refer this link before perusing other options : https://sapui5.hana.ondemand.com/#docs/guide/50897decc9504b2a875fb41d89fd254a.html

    Hope this solution helps .

    Regards,

    Toney C Benoy

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Toney,

      With your help I understand that using Service URL for mock data would not help but in the manifest file I have defined the Data Sources and default model for the app. After this step I got a metadata file under the localService folder.

      Now suppose I give the entity set to be bound in the Smart Table where would I specify the path for the app to locate the metadata file. I am struck with this path.

      Thanks,

      Srinivasan

  • avatar image
    Former Member
    Feb 15, 2017 at 05:12 PM

    One more thing to note, variant management will not work from web development (WebIDE or Eclipse) you have to deploy the code to ABAP repository then create a tile for your app in the launch pad, then your app will show-up in the launchpad where you can use variant management to save table changes and filter changes.

    Good Luck!!

    Add comment
    10|10000 characters needed characters exceeded