s-HR字段联动(字段显示隐藏/禁用启用/必录非必录)原创
金蝶云社区-吴建钦
吴建钦
4人赞赏了该文章 142次浏览 未经作者许可,禁止转载编辑于2024年05月10日 15:59:43

表单上的字段联动

设置必录的方法 
shr.execByFieldIdAndMethod(fieldName,'addRules',{'required':true}); 
设置非必录的方法 
shr.execByFieldIdAndMethod(fieldName,'removeRules','required'); 
设置只读的方法 
shr.execByFieldIdAndMethod(fieldName,'disable',null,_top.document); 
设置非只读的方法 
shr.execByFieldIdAndMethod(fieldName,'enable',null,_top.document); 
隐藏的方法 
$('#fieldName').parents('div[data-ctrlrole="labelContainer"]').hide(); 
显示的方法 
$('#fieldName').parents('div[data-ctrlrole="labelContainer"]').show();

表格的联动

设置必录的方法
var $grid = $('#' + gridId);
var prop = $grid.getColProp(colName);
prop.classes = 'required';
prop.required = true; 
if(prop.editoptions && prop.editoptions.validateJson){
 prop.editoptions.validateJson.rules = "required:true";
}else if(prop.editoptions){
 prop.editoptions['validateJson'] = {rules: "required:true"};
}
$grid.trigger('reloadGrid');
设置非必录的方法
var $grid = $('#' + gridId);
var prop = $grid.getColProp(colName);
prop.required = false;
prop.classes = '';
if(prop.editoptions 
&& prop.editoptions.validateJson 
&& prop.editoptions.validateJson.rules == "required:true"){
prop.editoptions.validateJson.rules = "";
}
$grid.trigger('reloadGrid');
设置只读的方法
var $grid = $('#' + gridId);
var prop = $grid.getColProp(colName);
prop.classes = 'disabled';
prop.editable = false;
$grid.trigger('reloadGrid');
设置非只读的方法
var $grid = $('#' + gridId);
var prop = $grid.getColProp(colName);
if(prop.required){
prop.classes = 'required';   
}else{
prop.classes = ''; 
};
prop.editable = true;
$grid.trigger('reloadGrid');
隐藏的方法
$('#grid').jqGrid('hideCol',colName);
$('#grid').jqGrid("resizeGrid",{base:$grid,offset:0});
显示的方法
$('#grid').jqGrid('showCol',colName);
$('#grid').jqGrid("resizeGrid",{base:$grid,offset:0});


赞 4