jQgrid:如何在“添加/编辑”对话框中将禁用的字段灰显?

jQgrid:如何在“添加/编辑”对话框中将禁用的字段灰显?,jqgrid,Jqgrid,我发现下面的链接可以帮助我灰色显示只读字段 但我在寻找一些东西,帮助我灰色的领域,是残疾 你有没有想过我该怎么做 编辑添加代码以更好地解释我的情况。我下面的所有示例都使用了上面链接中的灰色代码 这第一段代码与上面链接上的解决方案完美配合,以灰显只读部分。但是我们不得不把它改成一个选择列表 // // This grays out the field name and the input field. (But this had to be cha

我发现下面的链接可以帮助我灰色显示只读字段

但我在寻找一些东西,帮助我灰色的领域,是残疾

你有没有想过我该怎么做

编辑添加代码以更好地解释我的情况。我下面的所有示例都使用了上面链接中的灰色代码

这第一段代码与上面链接上的解决方案完美配合,以灰显只读部分。但是我们不得不把它改成一个选择列表

            //
            // This grays out the field name and the input field.  (But this had to be changed to a selection list for business reasons)
            //
            //{ name: 'tCode', index: 'tCode', width: 63, align: "left", editable: true, editoptions: { maxlength: "25", readonly: istCodeReadOnly } },
下一段代码将使所选内容变灰,但不会使其旁边的字段名变灰

//这会使所选内容变灰,但不会使字段名变灰
{
名称:'tCode',索引:'tCode',宽度:63,对齐:“左”,可编辑:true,编辑规则:{required:true},编辑类型:“选择”,编辑选项:{
禁用:istCodeReadOnly,
async:false,dataUrl:'@Url.Action(“GettCodes”,“Home”),
buildSelect:函数(结果){
var响应=$.parseJSON(结果);
var s='';
$。每个(响应、函数(){
s+=“”+this.description+“”;
});
返回s+“”;
}
}
},

这是第一次尝试什么都没有变灰。这就好像从未识别出只读字段。基本上什么也没发生

            // This does not gray out the field name or the field itself
            {
                name: 'tCode', index: 'tCode', width: 63, align: "left", editable: true, editrules: { required: true }, edittype: "select", editoptions: {
                    readonly: istCodeReadOnly,
                    async: false, dataUrl: '@Url.Action("GettCodes", "Home")',
                    buildSelect: function (result) {
                        var response = $.parseJSON(result);
                        var s = '<select>';
                        $.each(response, function () {
                            s += "<option value='" + this.code + "' > " + this.description + "</option>";
                        });
                        return s + "</select>";
                    }
                }
            },
//这不会使字段名或字段本身变灰
{
名称:'tCode',索引:'tCode',宽度:63,对齐:“左”,可编辑:true,编辑规则:{required:true},编辑类型:“选择”,编辑选项:{
只读:istCodeReadOnly,
async:false,dataUrl:'@Url.Action(“GettCodes”,“Home”),
buildSelect:函数(结果){
var响应=$.parseJSON(结果);
var s='';
$。每个(响应、函数(){
s+=“”+this.description+“”;
});
返回s+“”;
}
}
},

对不起,我不明白你的问题。你有什么问题?通过在输入框/选择或其他输入元素上设置
disabled
属性(
prop(“disabled”,true)
),不允许更改。通过将
“ui state disabled”
类添加到相同的字段或左侧相应的描述中,字段将变灰。我使用
editoptions:{readonly:“readonly”}
将一些列标记为只读,并设置了
readonly
属性。后来我另外设置了
disabled
属性,并添加了
“ui state disabled”
类。我不确定我是否理解您想要什么,但您可能可以通过将演示中的
$form.find(“.FormElement[readonly]”)替换为
$form.find(.FormElement:disabled)来解决您的问题
@Oleg标签保持常规颜色,但选择列表变灰。我想知道如何将标签变灰。只需将“ui状态禁用”类添加到标签。如果您有实现问题,您应该将使用的代码附加到问题中。例如,我不清楚如何禁用某些字段。不管怎样,代码或演示都可以让一切变得清晰,我可以帮助您。@Oleg添加了示例代码,以便更好地解释我的问题。希望这有助于解释它。
istCodeReadOnly
是一个布尔值,它根据后端的逻辑告诉我字段是否应为只读(true或false)。