Search This Blog

Wednesday, July 12, 2017

Enable and Disable controls inside a tab


 Enable / Disable a Section

function sectiondisable(sectionname, disablestatus) {
    var ctrlName = Xrm.Page.ui.controls.get();
    for (var i in ctrlName) {
        var ctrl = ctrlName[i];
        if (ctrl.getParent() == null)
            continue;
        var ctrlSection = ctrl.getParent().getName();
        if (ctrlSection == sectionname) {
            ctrl.setDisabled(disablestatus);
        }
    }
}


 Enable / Disable a Tab
function tabdisable(tabname, disablestatus) {
    var tab = Xrm.Page.ui.tabs.get(tabname);
    if (tab == null)
        return;
    else {
        var tabsections = tab.sections.get();
        for (var i in tabsections) {
            var secname = tabsections[i].getName();
            sectiondisable(secname, disablestatus);
        }
    }
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.