BPM实例分享:设置控件只读

适用于需要根据其余字段赋值显示的字段。

比如选择人员后自动带出的部门,比如某些需要动态禁用的字段。

 

针对sheetuser类型的字段,如部门,人员,适用如下方法 ,field为字段名,如果明细行,在field后增加行参数即可

 

//设置控件无法点击

        function setDisabled(field) {

            $.MvcSheetUI.GetElement(field).find("*").each(function () {

                $(this).unbind('click')

                    .unbind('focusin')

                    .prop("disabled", true);

            });

        }

 

 

针对下拉选择框,适用如下方法

 

$.MvcSheetUI.GetElement(field).prop("disabled", false)

 

 

针对弹出选择框

 

function setTextBoxReadonly(field, row, b) {

            var ele = $.MvcSheetUI.GetElement(field, row);

            var sheetText = ele.SheetUIManager();

            var textLable = ele.parent().find("label");

            if (b) {

                ele.hide();

                if (textLable != null && typeof (textLable) != "undefined") {

                    textLable.remove();

                }

                var lbl = $("");

                if (sheetText.TextRightAlign) lbl.addClass("txtAlignRight").css("width", ele.width());

                else if (sheetText.NumberRightAlign && sheetText.IsNubmer()) { lbl.addClass("txtAlignRight"); }

                var val = $.trim(sheetText.GetValue());

                if (val != "") {

                    var strs = val.split("\n");

                    $(strs).each(function (i) {

                        if (i > 0) {

                            lbl.append("

");

                        }

                        lbl.append($("").text(this.toString()));

                    });

                }

                lbl.insertAfter(ele);

                sheetText.GetFromatValue(lbl, sheetText.GetValue());

                ele.nextAll("a").hide();

            }

            else {

                ele.show();

                if (textLable != null && typeof (textLable) != "undefined") {

                    textLable.remove();

                }

                ele.nextAll("a").show();

            }

        }

posted @ 2017-03-27 14:22  流程控  阅读(454)  评论(0编辑  收藏  举报