MetabaseDialogBase.addFilter

Syntax

addFilter(filter: Object, index: Number, select: Boolean);

Parameters

filter. Filter. This parameter contains the Filters field: that is, an array containing items of the PP.Mb.Ui.MetabaseObjectClass,  enumeration, and the ResourceKe field that stores key of the resource required to get filter name

index. Position of added filter in the array

select. Indicates that the added filter will be set as the current one.

Description

The addFilter method adds a filter to a basic dialog box with repository.

Example

To execute the example, the HTML page must contain the MetabaseDialogBase component named metabaseDialogBase (see. Example of creating the MetabaseDialogBase component). Remove all filters from the dialog box, next add a new filter and set it as the current one:

// Deselect all filters from dialog box
metabaseDialogBase.clearFiltersSet()
console.log("Number of filters after deselection: " + metabaseDialogBase.getFiltersSet().length);
// Create a filter to display regular reports
var filter = {
    Filters: [2562], // Filter for regular reports
    // Resource key to get filter name
    ResourceKey: "openDialogReports"
};
// Add this filter and select it as current
metabaseDialogBase.addFilter(filter, 1, true);
console.log("Number of filters after adding: " + metabaseDialogBase.getFiltersSet().length);
// Get current filter
var currentFilter = metabaseDialogBase.getCurrentFilter();
console.log("Current filter: " + PP.resourceManager.getString(currentFilter.ResourceKey).Content);

After executing the example first all filters are removed from the dialog box, next a new filter that shows regular report is added and set as the current filter. Appropriate messages are shown in the browser console:

Number of filters after clearing: 0
Number of filters after adding: 1
Current filter: Regular reports

See also:

MetabaseDialogBase