on 02-09-2017 11:22 AM
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 the following parameter to your smart table:
initiallyVisibleFields="Kunnr1,Name1"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srini,
Metadata is data about data.. means i holds the properties
Using this (/sap/opu/odata/SAP/ZCFS_CUSTOMER_LIST_SRV/) you are pointing to SAP system right using mock data don't work like that . i think you have to maintain a metadata file as well as a data that contains the value to show it in the smart table .
I hope this information helps
Regards,
Toney C Benoy
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Veera,
Thank you for your reply. I have shared the Smart Table binding below for our reference.
<smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="ZCFS_Cust" persistencyKey="SmartFilter_Explored" basicSearchFieldName="Kunnr" enableBasicSearch="true">
<smartFilterBar:controlConfiguration>
<smartFilterBar:ControlConfiguration key="Kunnr">
<smartFilterBar:defaultFilterValues>
<smartFilterBar:SelectOption low="301676">
</smartFilterBar:SelectOption>
</smartFilterBar:defaultFilterValues>
</smartFilterBar:ControlConfiguration>
<smartFilterBar:ControlConfiguration key="Name1">
<smartFilterBar:defaultFilterValues>
<smartFilterBar:SelectOption low="Robs Solutions">
</smartFilterBar:SelectOption>
</smartFilterBar:defaultFilterValues>
</smartFilterBar:ControlConfiguration>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<smartTable:SmartTable id="LineItemsSmartTable" entitySet="ZCFS_CustSet" smartFilterId="smartFilterBar" tableType="Table" useExportToExcel="true" useVariantManagement="true" useTablePersonalisation="true" header="Line Items"showRowCount="true" persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true" demandPopin="true" app:useSmartField="true">
</smartTable:SmartTable>
Regards,
Srinivasan
Hello Srinivasan,
I think since no fields are visible in your smart name , there is no binding being triggered.
Couple of ways to quickly check this.
1. Click on the settings button select any column and click ok, this should trigger the data.
2. Add some fields in the attribute InitiallyVisibleFields ="Field1,Field2"(couple of fields in the entity).
If the above works you have 2 solutions
Do as #2 mentioned above or use Lineitem annotations in backend to fix the issue.
Thanks and Regards,
Veera
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.