Dictionary.Filter

Syntax

Filter: Object;

Parameters

dict. MDM dictionary.

filter. Object that contains filter options.

callback. Callback function.

Description

The Filter property sets filter for MDM dictionary elements.

Comments

Use the setFilter method to set the property value, and the getFilter method to get the property value. Property value cannot be set from JSON.

The following two parameters are used on calling the setFilter method: filter - object that contains filter settings in metadata format, elsMd - dictionary elements as metadata to be filtered.

The getFilter method gets object that contains filter settings in metadata format.

Example

To execute this example, the page must contain the DictionaryBox component named dictionaryBox (see Example of creating the DictionaryBox component ). Filter dictionary elements by the Second string:

var source = dictionaryBox.getSource()[0];
// Get service to work with dictionary
var service = source.getPPService();
// Callback function
function onFilterElementsReceived(sender, args) {
    var res = JSON.parse(args.ResponseText);
    var dict = args.Args.Dictionary;
    var filter = args.Args.Filter;
    // Set filter
    dict.setFilter(filter, PP.getProperty(res, "GetRdsElementsResult.els.e"));
    // Call the ChildLoaded event
    service.ChildLoaded.fire(service, {
        Dictionary: dict,
        ParentKey: "",
        IsFilter: true
    });
    // Get tree of MDM dictionary elements
    var tree = dictionaryBox.getDataArea().getActiveDictTree();
    tree._Filter = filter;
    // Load all elements that are child elements of the tree root
    tree.setChildNodes("");
};
// Define filter settings
var filter = {
    levels: -1,
    text: {
        text: "Second" // Search bar
    }
};
// Determine request to be sent to server
var body = {
    GetRdsElements: {
        tRds: source.getOdId(),
        tArg: {
            showHidden: source.getShowHidden(),
            filter: filter, // Specify filter
            pattern: {
                attributes: "*",
                getHasChildren: true,
                getLevel: true,
                getParentKey: true,
                getHistory: true
            }
        }
    }
};
// Send the request
service._send(body, PP.Delegate(onFilterElementsReceived, service, {
    Filter: filter,
    Dictionary: source
}));

After executing the example MDM dictionary elements are filtered by the line "Second":

See also:

Dictionary