1.设置控件只读
Xrm.Page.ui.controls.get("new_forecasttype").setDisabled(true);
Xrm.Page.controls.("new_forecasttype").setDisabled(true);
--选项卡是否可见
Xrm.Page.ui.tabs.get("tab_3").setVisible(false);
--选项卡下的节点是否可见
Xrm.Page.ui.tabs.get("tab_5").sections.get("tab_5_section_1").setVisible(false);
二.设置整个表单只读(下拉也会被禁用)
document.body.disabled = true;
三 MSCRM禁用标签页内所有组件
//已经审核的单据禁止修改
if (Xrm.Page.getAttribute("new_status").getValue() == 2) {
disableTab(0);
}
//禁用标签
function disableTab(tabIndex) {
var tab = document.all["tab" + tabIndex];
for (var i = 0; i < tab.all.length; i++) {
if (tab.all[i].Disabled !== undefined) {
tab.all[i].Disabled = true;
}
}
}
四.怎样用客户端JScript实现区域的只读属性(这个比较好)
function onLoad() {
setDisabled(document.getElementById("formContainer"), { table: '', iframe: '', div: '', form: '', col: '', colgroup: '', lable: '', span: '', tbody: '', body: '', tr: '', td: '' }, true);
}
/*
setDisabled function
1. set readOnly property for INPUT/TEXTAREA nodes
2. disable other nodes
id: element's Id
ignoreNodes: nodes can be ignored
nodesDisabled: bool, true = set disable/readonly
*/
function setDisabled(id, ignoreNodes, nodesDisabled) {
var node, nodes;
nodes = id.getElementsByTagName('*');
if (!nodes)
return;
var i = nodes.length;
while (i--) {
node = nodes[i];
if (node.nodeName && !(node.nodeName.toLowerCase() in ignoreNodes)) {
if ((node.nodeName == "INPUT") || (node.nodeName == "TEXTAREA")) {
node.readOnly = nodesDisabled;
}
else {
node.disabled = nodesDisabled;
}
}
}
}