Call it during On load (with certain condition) then all the sub grid add button in the form will be hidden.
Script:
var intervalId;
function makeReadOnly() {
try {
var subgridsLoaded = false;
Xrm.Page.ui.controls.get().forEach(function (control, index) {
if (control.setDisabled && Xrm.Page.ui.getFormType() != 3) {
control.setDisabled(true);
}
else {
// removeAddButtonFromSubGrid(control);
// subgridsLoaded = true;
}
});
if ($("div[id$='_crmGridTD']").length > 0 && !subgridsLoaded) {
intervalId = setInterval(function () {
var subgridsArr = Xrm.Page.getControl(function (control, index) {
return control.getControlType() == 'subgrid';
});
subgridsArr.forEach(function (control, index) {
removeButtonsFromSubGrid(control);
});
}, 500);
}
}
catch (e) {
alert("makeReadOnly() Error: " + e.message);
}
}
function removeButtonsFromSubGrid(subgridControl) {
if (intervalId) {
$('#' + subgridControl.getName() + '_addImageButton').css('display', 'none');
$('#' + subgridControl.getName() + '_openAssociatedGridViewImageButton').css('display', 'none');
clearInterval(intervalId);
}
}
CRM 2013 Remove all the subgrid add button
Posted by Unknown at 1/13/2015 02:29:00 pm
Labels: CRM 2013, Javascript
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment