cancel
Showing results for 
Search instead for 
Did you mean: 

Smart Table - Custom Filter

0 Kudos

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=(Vbe...

Please help me, where I am doing the mistake.

Also I have attached the screen short of url.

Thanks & Regards,

Dhiraj

piyush_831
Discoverer
0 Kudos

Hi. Did your issue resolve ? I am facing the same issue. Also what is p13ndata in your code ?

Accepted Solutions (0)

Answers (1)

Answers (1)

iftah_peretz
Active Contributor
0 Kudos

Hi,

In each time you want to filter just by one vbeln? Is the place you do that is only in onBeforeRebindTablePacked? if so do this

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