Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Karol-K
Advisor
Advisor

The global filters - a functionality frequently requested when talking about the online composition scenario.

The issue

Using the components "Fragment Gallery" and "Split Cell Container" you an easily allow users to create own fragments (called also smart objects) and dashboards. The only issue (or feature) was - every single fragment contains of the visualization and data source with all filter values. Now, when placing into split cell container it stays on the filters which were assigned at the creation time. Change of those is not possible at all, as there is no access to the data source (as those were dynamically created at runtime and have some generated name).

The solution

There is a new function in Split Cell Container -

SPLITCELLCONTAINER_1.getDataSources();

Using this function you can now access the data sources included in the split cell container.

In connection with Filter Panel function


FILTERPANEL_1.setDataSource(dataSourceAlias);


you can take the first data source and assign to the filter panel which will get the members from this data source.

How to find the first data source?

In split cell container, there is an event on Drop", there you can place this script:


var dataSources = SPLITCELLCONTAINER_1.getDataSources();



dataSources.forEach(function(element, index) {


  if(index == 0) {


  FILTERPANEL_1.setDataSource(element);


  }


});


(consider also some script in the "on Delete" event...)

How to distribute the filters?

In the "on Apply" event, you can again loop at all data sources of the split cell container and copy the filters.


var allDataSources = SPLITCELLCONTAINER_1.getDataSources();


var masterDataSource = FILTERPANEL_1.getDataSource();



allDataSources.forEach(function(element, index) {


  if (element != masterDataSource) {


  element.copyFilters(masterDataSource);


  }


});


Other aspects

The same way can be used with Filter Line component. There is not "on Accept" event, but there is a script function


FILTERLINE_1.setTargetDataSources(datasources);


which makes logically a filter copy.

Example.

For an example of this functions, you can refer to the template "Online Composition" (New -> select the template) and its function:

Questions, Ideas welcome.

4 Comments