Skip to Content
0

Smart Table is not getting updated after applying custom filter

Feb 20 at 12:01 PM

262

avatar image
Former Member

Hello,

I am facing pretty annoying issue with Smart Table, I have extended Filter with my own Filters and setting those filters in even onBeforeRebindTableExtension.

It is strange that sometimes data are shown in the table, but mostly not. If I change the filter value nothing gets update, however in Network Tab I see that data were transferred.

In case when it does show something in Smart Table if I click on GO button again table won't show anything.

here is how my Fragment looks like

<core:FragmentDefinition xmlns="sap.m" xmlns:smartfilterbar="sap.ui.comp.smartfilterbar" xmlns:core="sap.ui.core">
	<!-- Date Filter -->
	<smartfilterbar:ControlConfiguration key="YearMonthFilter" index="1" label="{i18n>label_YearMonth}" visibleInAdvancedArea="true"
		groupId="_BASIC"  >
		<smartfilterbar:customControl>
			<Input id="YearMonth"  placeholder="JJJJMM" />
		</smartfilterbar:customControl>


	</smartfilterbar:ControlConfiguration>
</core:FragmentDefinition>

Here is my Controller Extension

sap.ui.controller("myrep.ext.controller.ListReportExt", {
onBeforeRebindTableExtension: function(oEvent) {
		debugger;
		var mBindingParams = oEvent.getParameter("bindingParams");
		mBindingParams.parameters = mBindingParams.parameters || {};


		// Custom Filter for Customer ID
		var sCustomerId = this.getJwtProperty("KUNNR"); // for tests it is "0000001006"
		if (sCustomerId) {
			var oCustomerFilter = new sap.ui.model.Filter("CustomerId", sap.ui.model.FilterOperator.EQ, sCustomerId);
		}


		var oSmartTable = oEvent.getSource();
		var oSmartFilterBar = this.byId(oSmartTable.getSmartFilterId());
		var oYearMonthControl = oSmartFilterBar.getControlByKey("YearMonthFilter");


		var sYearMonth = oYearMonthControl.getValue();
		if (sYearMonth) {
			var oYearMonthFilter = new sap.ui.model.Filter("YearMonth", sap.ui.model.FilterOperator.EQ, sYearMonth);
		}
		var oMyFilters;


		oMyFilters = new sap.ui.model.Filter({
			filters: [
				oYearMonthFilter,
				oCustomerFilter
			],
			and: true
		});


		if (oMyFilters) {
			mBindingParams.filters.push(oMyFilters);
		}

},

Below is the case when it works

And here is when it doesn't update

smartable.png (21.7 kB)
network.png (106.8 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Feb 27 at 01:52 PM
0

Update>

The application runs as standalone app, which in turn is integrated via iframe into webpage. Due to security I have to pass JWT Token to backend and set CustomerId Filter for a customer which is logged in on web site.

I found out that when I have set presentation variant with grouping it is not getting refreshed, if I remove grouping it works fine.

It also works fine when I do not extend filterbar

So I am not sure if it is an issue of the respective Template or is it behaving strange due to the fact it runs inside an iframe. but for now I have this workaround

Share
10 |10000 characters needed characters left characters exceeded