Snippets

Piotr Szrajber Geospatial Portal - Modify attribute Display Names in the Feature Info Control for PSS

Created by Piotr Szrajber
/*
 * Modify attribute Display Names in the Feature Info Control for PSS
 * This snippet overwrites core method and uses newly introduced AliasName taken
 * from a global dictionary of aliases that can be modified in runtime.
 * 2017-11-24 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
 */
Sys.Application.add_init(function() {
    $ALIAS_NAMES = {
        "Field1": "Another name for the first field",
        "Field2": "Other name for field 2"
    }

    // add additional custom field to the store using global dictionary of aliases
    function addAliases(items) {
        for (var i = 0, l = items.length; i < l; i++) {
            items[i].data.AliasName = $ALIAS_NAMES[items[i].data.Name] || items[i].data.Name;
        }
    }

    // overwrite the core - change the column used for displaying "Name" and execute custom method on the store
    var orig = Intergraph.WebSolutions.Core.WebClient.Controls.FeatureInfoControl.prototype._getAttributeGroupPanel;
    Intergraph.WebSolutions.Core.WebClient.Controls.FeatureInfoControl.prototype._getAttributeGroupPanel = function() {
        // ATTENTION PLEASE!!! Make some check for particular feature classes in order not to break other feature infos :)
        var ret = orig.apply(this, Array.prototype.slice.call(arguments));
        ret.columns[0].dataIndex = "AliasName";
        addAliases(ret.store.data.items);
        return ret;
    }
});

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.