2013-12-12 53 views
1

在我的jqGrid中,我想从模型中传入5行,并在网格中显示其中的3个,但所有5个都显示在编辑中并添加jqGrid生成的弹出窗口。我知道我可以在colModel设置中添加hidden: true属性,以防止它显示出来,但这也会从弹出窗口中隐藏它。是否有某种方法隐藏网格中的列,但在添加或编辑数据时显示它?隐藏jqGrid显示的列,但在编辑/添加屏幕中显示它?

我的网格代码:

<script type="text/javascript"> 
    $(document).ready(function() 
    { 
     $('#Sections').jqGrid({ 
      url: '@Url.Action("GetData")', 
      datatype: 'json', 
      mtype: 'GET', 
      colNames: ['ID', 'RouteName', 'Title', 'File', 'Description'], 
      colModel: [ 
         { name: 'ID', index: 'ID', width: 10, sorttype: 'int' }, 
         { name: 'RouteName', index: 'RouteName', width: 50, editable: true, edittype: 'text'}, 
         { name: 'Title', index: 'Title' }, 
         { name: 'File', index: 'File', hidden: true }, 
         { name: 'Description', index: 'Description', hidden: true } 
      ], 
      autowidth: true, 
      height: '100%', 
      pager: $('#SectionsPager'), 
      sortname: 'ID', 
      viewrecords: true, 
      loadonce: true, 
      ignoreCase: true, 
      multiSort: true, 
     }); 
     $('#Sections').jqGrid('navGrid', '#SectionsPager', 
      //enabling buttons 
      { add: true, del: false, edit: true, search: true }, 
      //add options 
      { width: 'auto' }, 
      //edit options 
      { width: 'auto' }, 
      //delete options 
      {} 
     ); 
    }); 
</script> 

回答

3

通过Oleg的答案在

Sending additional parameters to editurl on JQgrid

hidden: true, editable: true, editrules: { edithidden: true}, hidedlg: true 

编辑时,editrules: { edithidden: true}部分将“打开”您的列。

+0

你在哪里关闭'eddithidden'需要设置为'true'不是false,如果你更新了你的答案,我会将它标记为正确的。 – Matthew

+0

@MatthewVerstraete完成 – Mark

0

ü可以在添加/编辑使用beforeShowForm,使其隐藏或不

beforeShowForm: function(form) { 
$("#tr_columnname").hide(); 
    $("#tr_columnname").show(); 
} 
+0

哪里在我的代码库将被放置? – Matthew

相关问题