Skip to Content
0

Odata service triggering twice

Feb 23 at 07:08 AM

135

avatar image
Former Member

Hi Experts,

I am using a smart table feature in my ui5 application, And i am using setEntity() method to set the entity Set Property to a smart table from the controller, it is working fine but the Problem is oData Service call is triggering twice, So i need your help to fix this.

Please find the below ui5 code :

View.xml:

<smartTable:SmartTable id="smartTableId" useExportToExcel="true" tableType="ResponsiveTable" useVariantManagement="true" useTablePersonalisation="true" showTablePersonalisation="true" header="Line Items" showRowCount="true"
persistencyKey="details.smartTable" enableAutoBinding="true" class="sapUiResponsiveContentPadding" beforeRebindTable="onBeforeRebindTableExtension" requestAtLeastFields="ID,Name">
</smartTable:SmartTable>

Controller:

onInit:function()
{
var entity ="Results";
var oTable = this.getView().byId("smartTableId");
oTable.setEntitySet(entity);
oTable.rebindTable(true);
}

i am able to set the entitySet to the smart table but, it is triggering oData service twice.

Network Tab:

Please find the Results and count call triggering twice when i run the app .

Any suggestion would be a great help.

Thanks in advance,

Regards,

Pradeep

capre.png (101.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Joseph BERTHE Feb 26 at 12:39 PM
2

Hello,

In your manifest,json modify your model setting with the count mode to Inline.

Regards,

Joseph

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Joseph,

you mean to say defaultCountMode to inline?

Thanks,

Pradeep

0

I mean this :

Regards,

Joseph

screenshot-22.png (81.1 kB)
1
Vaibhav Maheshwari Feb 23 at 08:21 AM
1

hi Pradeep,

Try using the entityset Property of the smart table control in the View and then you won't need to set it in the init method..

It should resolve your issue

Thanks,

Vaibhav

Show 9 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Vaibhav,

Thanks for the reply, and I need to set the entitySet dynamically, i mean to say we have a date as input parameters in entitySet so i have to update the entitySet accordingly, so i am doing it through the setEntitySet method.

is there any way to update the entityset in smart table dynamically?

Regards,

Pradeep

0

Hi Pradeep,

Can you try updating the entityset in the onBeforeRebindTable event of the Smart Table control instead of the init method of controller ?

Thanks,

Vaibhav

0
Former Member

Hi Vaibhav,

Tried with that also, it did not work :(

Thanks

Pradeep

0

Hi Pradeep,

Seems like issue is somewhere else in your code. Are you resetting or refreshing values like filter/sorter in any other method ? Also check if your manifest file is configured properly.

Try setting the entity set name in the view once to check if the application still triggers call to back-end twice ?

i tried the same approach as yours and the call was triggered only once.

onInit: function() {
var entitySet = "OrderOperationSet";
var oTable = this.getView().byId("LineItemsSmartTable");
oTable.setEntitySet(entitySet);
oTable.rebindTable(true);
},

Thanks,

Vaibhav

network.png (13.3 kB)
1
Former Member
Vaibhav Maheshwari

HI ,

Can you please share the xml code for the same?

Thanks

Pradeep

0

hi Pardeep,

This is my view code :

<mvc:View controllerName="orderconf.controller.InitialView" xmlns:core="sap.ui.core" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" xmlns:smartTable="sap.ui.comp.smarttable"
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1" displayBlock="true" xmlns="sap.m" xmlns:t="sap.ui.table">
<smartFilterBar:SmartFilterBar id="smartFilterBar" entityType="OrderOperation" search="SearchEvt" persistencyKey="SmartFilter_Explored"
basicSearchFieldName="" enableBasicSearch="false" beforeVariantSave="beforeVariantSave" afterVariantLoad="afterVariantLoad" >
<smartFilterBar:controlConfiguration>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<Bar>
<contentLeft>
<Button id="DownloadPDFBtn" text="Download PDF" press="onPDFDownload"></Button>
<Button id="EnterConfBtn" text="Enter Confirmation" press="onEnterConfirmation"></Button>
</contentLeft>
</Bar>
<smartTable:SmartTable id="LineItemsSmartTable" smartFilterId="smartFilterBar" tableType="Table"
useExportToExcel="true" useVariantManagement="false" useTablePersonalisation="false" showRowCount="true" header="Order Confirmation List"
beforeRebindTable="beforeRebindTable" persistencyKey="SmartTableAnalytical_Explored" showFullScreenButton="true" enableAutoBinding="true" app:useSmartField="true">
<smartTable:layoutData>
<FlexItemData growFactor="1" baseSize="0%"/>
</smartTable:layoutData>
</smartTable:SmartTable>
</mvc:View>
0
Former Member

Hi Vaibhav,

I am applying the filter and sort on beforeRebindTable , is that is the problem?

Thanks,

Pradeep

0

Hi Pradeep,

Can you please share the code of your onBeforeRebindTable method ?

Thanks,

Vaibhav

0
Former Member
Hi Vaibhav,

Please find below for the code in onBeforeRebindTable method

onBeforeRebindTableExtension: function(oEvent) {


			var oBindingParams = oEvent.getParameter("bindingParams");
			//initially sort the table Rdate descending, so the last synchronizations are shown first
			if (!oBindingParams.sorter.length) {
				oBindingParams.sorter.push(new sap.ui.model.Sorter("EVT_DATE", true));
			}


			var vehicleID = this.byId('id1');
			var vehicleName = this.byId('id2');
			


			if (vehicleID.getValue() !== null && vehicleID.getValue() !== "") {
				oBindingParams.filters.push(new sap.ui.model.Filter("TYPE", "EQ", vehicleID.getValue()));
			}
			if (vehicleName.getValue() !== null && vehicleName.getValue() !== "") {
				oBindingParams.filters.push(new sap.ui.model.Filter("NAME", "EQ", vehicleName.getValue()));
			}
			


		}
<br>
0