Skip to Content
0
Jul 16, 2017 at 04:31 AM

Smart Table - Custom Filter

2335 Views

Hi Expert,

I am facing the problem when I am doing the filter based on the input filed in Smart Table.

Note : I am not using Smart Filter Bar.

Below are the step which I have done:

1) In header, Input field is there. Based on input value I am passing in the filter parameter on the method of smart table :

Below is the code:

_bindPackedTable: function() { var oSmartTablePacked = this.byId("smartTableLineItem"); oSmartTablePacked.attachBeforeRebindTable(this.onBeforeRebindTablePacked, this); oSmartTablePacked.rebindTable();

--------------------------------------------

onBeforeRebindTablePacked: function(oEvent) { // Get bindinParams Object, which includes filters var oBindingParams = oEvent.getParameter("bindingParams"); oBindingParams.filters.push(new sap.ui.model.Filter("Vbeln", sap.ui.model.FilterOperator.EQ, this.oSearchDelNo)); },

---------------------------------------------

2) test.view.xml code:

<Input id="idSearchDelvNo" width="150px"> <layoutData> <OverflowToolbarLayoutData minWidth="200px" maxWidth="300px" shrinkable="true"/> </layoutData> </Input> <Button text="Get Data" press="pressGetData" type="Emphasized"/>

SmartTable :

-----------------

<smartTable:SmartTable id="smartTableLineItem" header="Items to be Packed" entitySet="huTabSet" showRowCount="false" useOnlyOneSolidToolbar="true" useVariantManagement="false" useExportToExcel="false" initiallyVisibleFields="Posnr,Charg,Parqty,Matnr,Vhilm,Vbeln" tableType="Table" useTablePersonalisation="true" persistencyKey="SmartTableAnalytical_Explored" enableAutoBinding="true" app:useSmartField="false" class="sapUiResponsiveMargin sapMarginTopZero sapTableMarginRight"> <smartTable:noData> <Text text="No Data"/> </smartTable:noData> <!--Layout data used to make table growing true--> <uit:Table id="innerUI5Table_huTab" selectionMode="MultiToggle" visibleRowCount="5" growingScrollToLoad="true"> <uit:columns> <uit:Column width="120px" hAlign="Left"> <Label text="{/#huTab/Posnr/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Posnr","maxLength":"8","columnIndex":"0","leadingProperty":"Posnr"}'/> </uit:customData> <uit:template> <Text text="{Posnr}"/> </uit:template> </uit:Column> <uit:Column width="120px" hAlign="Center"> <Label text="{/#huTab/Charg/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Charg","maxLength":"8","columnIndex":"1","leadingProperty":"Charg"}'/> </uit:customData> <uit:template> <Text text="{Charg}"/> </uit:template> </uit:Column> <uit:Column width="120px" hAlign="Center"> <Label text="{/#huTab/Parqty/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Parqty","maxLength":"8","columnIndex":"2","leadingProperty":"Parqty"}'/> </uit:customData> <uit:template> <Text text="{Parqty}"/> </uit:template> </uit:Column> <uit:Column width="120px" hAlign="Center"> <Label text="{/#huTab/Matnr/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Matnr","maxLength":"8","columnIndex":"3","leadingProperty":"Matnr"}'/> </uit:customData> <uit:template> <Text text="{Matnr}"/> </uit:template> </uit:Column> <uit:Column width="120px" hAlign="Center"> <Label text="{/#huTab/Vhilm/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Vhilm","maxLength":"8","columnIndex":"4","leadingProperty":"Vhilm"}'/> </uit:customData> <uit:template> <Text text="{Vhilm}"/> </uit:template> </uit:Column> <uit:Column width="120px" hAlign="Right"> <Label text="{/#huTab/Vbeln/@sap:label}"/> <uit:customData> <core:CustomData key="p13nData" value='\{"columnKey":"Vbeln","maxLength":"8","columnIndex":"5","leadingProperty":"Vbeln"}'/> </uit:customData> <uit:template> <Text text="{Vbeln}"/> </uit:template> </uit:Column> </uit:columns> </uit:Table> </smartTable:SmartTable>

-----------------------------------

3) Based on the pressGetData function, I am getting the correct data in smart table.

But my problem is that when I press the same event(pressGetData) second time or multiple time, that time same parameters is going multiple time in filter parameters so getting the repeated data in table.

Below are the url :

Request URL: http://localhost:51073/sap/opu/odata/pweaver/UI_SHIP_SRV/packingTabSet?$skip=0&$top=105&$filter=(Vbeln%20eq%20%2780000005%27%20or%20Vbeln%20eq%20%2780000005%27)&$select=Item%2cWeight%2cDimensions%2cTrack

Please help me, where I am doing the mistake.

Also I have attached the screen short of url.

Thanks & Regards,

Dhiraj

Attachments

smarttable1.jpg (23.6 kB)