jqGrid中的隐藏列 [英] Hidden Columns in jqGrid

查看:1275
本文介绍了jqGrid中的隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法隐藏jqGrid表中的列,但是当在表单编辑器模式对话框中编辑行时,它是否显示为只读?

Is there any way to hide a column in a jqGrid table, but have it show as read-only when the row is edited in the form editor modal dialog?

推荐答案

我只是想扩展 queen3 的建议,应用以下技巧:

I just want to expand on queen3's suggestion, applying the following does the trick:

editoptions: { 
              dataInit: function(element) { 
                          $(element).attr("readonly", "readonly"); 
                        } 
             }

场景#1


  • 字段必须在网格中可见

  • 字段必须以
  • 字段必须是只读的

解决方案

colModel:[
        {  name:'providerUserId',
               index:'providerUserId', 
               width:100,editable:true, 
               editrules:{required:true}, 
               editoptions:{ 
                            dataInit: function(element) { 
                                  jq(element).attr("readonly", "readonly"); 
                             } 
                           }
            },
],

providerUserId在网格中可见,在编辑表单时可见。但是你无法编辑内容。

The providerUserId is visible in the grid and visible when editing the form. But you cannot edit the contents.

场景#2


  • 字段必须在网格中不可见

  • 字段必须在表单中可见

  • 必须读取字段-only

解决方案

colModel:[
           {name:'providerUserId',
            index:'providerUserId', 
            width:100,editable:true, 
            editrules:{
                         required:true, 
                         edithidden:true
                      },
            hidden:true, 
            editoptions:{ 
                  dataInit: function(element) {                     
                             jq(element).attr("readonly", "readonly"); 
                          } 
                     }
         },
        ]

请注意,在两个实例中我都使用jq来引用jquery,而不是通常的$。在我的HTML中,我有以下脚本来修改jQuery使用的变量:

Notice in both instances I'm using jq to reference jquery, instead of the usual $. In my HTML I have the following script to modify the variable used by jQuery:

<script type="text/javascript">
    var jq = jQuery.noConflict();
</script>

这篇关于jqGrid中的隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆