Skip to Content
Technical Articles

Filter the Visual Filters in Analytical List Page

Visual Filters are the most appealing part of the Analytical List Page and there is so much that can be done with these filters.

I’m going to keep this very short as this is my first blog post. This is a quick trick on how to filter the visual filters of ALP using onBeforeRebindVisualFilterExtension.

 

Pre-requisites

Familiar with Analytical List Page (ALP) developer extension. If not, please go through this blog post https://blogs.sap.com/2019/08/24/analytical-list-page-alp-developer-extension/

 

Use-case scenario:

District is passed from Overview Page using intent based navigation. Visual Filter for Field Service Engineer should only show the relevant values for the District value passed from ovp.

 

onBeforeRebindVisualFilterExtension()

onBeforeRebindVisualFilterExtension: function (sEntityType, sDimension, sMeasure, oContext) { // oContext has filters, queryParameters, sorters, entityParameters applicable for this specific visual filter 
		"use strict";
		var oNavigationContext = this.extensionAPI.getNavigationContext(); //getting incoming navigation context through extension API  

		var dist = 0;
		if (oNavigationContext.SelectOptions) {
			for (var i = 0; i < oNavigationContext.SelectOptions.length; i++) {
				if (oNavigationContext.SelectOptions[i].PropertyName === "District") {
					dist = oNavigationContext.SelectOptions[i].Ranges[0].Low;
				}
			}
		}

		if (sDimension === "FieldServiceEngineer") {
			if (dist !== 0) {
				oContext.filters.push(new sap.ui.model.Filter("District", "EQ", dist));
			}
		}
	}

 

Well, that’s about it. Happy coding!

Be the first to leave a comment
You must be Logged on to comment or reply to a post.