【问题标题】:don't want to show all the records grid view in jqgrid不想在 jqgrid 中显示所有记录网格视图
【发布时间】:2013-12-07 07:12:56
【问题描述】:

这是在网格上显示所有记录的网格视图,但我不想在网格中显示所有记录? 当我点击添加、编辑、查看等事件时,会显示所有记录...

假设在我的网格中显示“总计”,只有当我单击添加、编辑、查看时才会显示总计 不在网格视图中

 colModel:[

 {name:'empId',index:'empId',width:3,editable:true,editoptions:{readonly:false,view:true},editrules:{required:false},key:true,formoptions:{rowpos:2,elmprefix:"    " }},
    {name:'empName',index:'empName',width:3,editable:true,editrules:{required:true},formoptions:{rowpos:3,elmprefix:"    " }}]

    jQuery("#taskDetails").jqGrid('navGrid','#pagernavTask',{add:true,edit:true,del:true,refresh:true,view:true,search:false})

这是我的代码...假设如果我 add id,name (editable:true) 它显示对话框 2 字段 ..并且它也显示在网格视图中 ,,but 和 don '不想在网格视图显示中显示,它仅在我单击编辑、添加、查看时显示(显示在对话框中)..可能吗????请回复此答案

请任何人给我答案

提前感谢

【问题讨论】:

    标签: jqgrid


    【解决方案1】:

    可以通过在 colModel 中使用 hidden: true 来隐藏列。此外,通过在添加、编辑、视图中使用 beforeshowform,您可以自定义显示/隐藏列的方式。欲知详情Hidden Columns in jqGrid

    更新

    在这里,我通过在我的 colmodel 中使用 hidden:true 来隐藏 EmpId。它可以通过使用 beforeshowform 事件显示在添加对话框中。与我在网格中显示 empName 但在编辑对话框中隐藏的方式相同。希望你现在能理解。

    $(function() {  
    var grid = $('#MyJqGrid');
    var mydata = [ 
                    {empId:"1",empName:"alpha",notes:"NA"},
                    {empId:"2",empName:"beta",notes:"Null"},
                    {empId:"3",empName:"gamma",notes:"N/A"},
                    {empId:"4",empName:"delta",notes:"Null"},
                    {empId:"5",empName:"theta",notes:"aaaa"},
                 ];
    grid.jqGrid({
        data: mydata,
        datatype: "local", 
        colNames:['empId','empName', 'Notes'],
        colModel:[ 
                    {name:'empId',index:'empId',sortable:true, editable:true, hidden: true,}, // here field is hidden in grid
                    {name:'empName',index:'empName',editable:true, sortable: true, hidden: false,}, // here field is shown in grid
                    {name:'notes',index:'notes',editable:true, sortable: true,},
        ],
        height: "auto",
        width : "auto",
        pager:'#Mypager',
        viewrecords : true,
        rowNum: 5,
        sortname: "empId",
        sortorder :"asc",
        rowList:[2,3,5],
        caption : "My JqGrid Test",
    }).jqGrid('navGrid','#Mypager',{
            edit: true,
            add: true,
            del: false, 
            search: false, 
            view: false, 
            },
            {
                //Edit Form
                beforeShowForm: function(form){
                    $('#tr_empName',form).hide(); //In Edit form empName is Hidden, initially shown
                }
            },
            {
                //Add Form 
                beforeShowForm: function(form){
                        $('#tr_empId',form).show(); //In add form EmpId is shown, initially hidden 
                        //$('#tr_empName',form).hide();
            },              
        });
    

    });

    【讨论】:

    • 感谢您的回复..我知道隐藏但是当我隐藏一列时...当我单击查看该隐藏字段未显示时..我想查看该字段未显示的字段网格视图
    • @manasvi 如果是这种情况,你会得到什么错误。请详细说明
    • 我没有收到任何错误,但没有在网格中删除..我想要删除字段。我将 beforeshowform 放在 colmodel 一个字段中,但它再次显示
    • 感谢您的回复,,,,写了一些代码,看我上面的代码我编辑了..请回复
    • @manasvi 我创建了一个小型工作演示,我在我的答案中进行了更新
    猜你喜欢
    • 1970-01-01
    • 2011-07-13
    • 2021-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    • 2015-05-20
    相关资源
    最近更新 更多