0

This is the grid view showing all records on grid here, but i don't want show in the grid all records? When ever i click events like add,edit,view,in that time shows the all records...

Suppose showing' Total' in my grid ,,Total is showing only when i click add ,edit ,view Not in the grid view

 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})

This is my code...suppose if i add id,name (editable:true) it show dialogue box 2 feilds ..and also it shows in grid view also ,,but and don't want to display in the grid view displays ,it show only when i click edit,add,view (show in dialogue boxes)..Is it possible ????Please reply for this answer

Please any one give me the answer

Thanks in adavance

manasvi
  • 11
  • 1
  • 5

1 Answers1

0

hiding a column can be done by using hidden: true in your colModel. Moreover by using beforeshowform in your add ,edit ,view u can customize ur own way of showing / hiding a column. For advance details Hidden Columns in jqGrid.

UPDATE

here i hide EmpId by using hidden:true in my colmodel. it can be shown in Add dialog by using beforeshowform event. Same way i have shown empName in Grid but hidden in edit dialog. hope u can understand now.

$(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();
        },              
    });

});

Community
  • 1
  • 1
Wahab
  • 520
  • 5
  • 24
  • Thanks for your reply ..i know hidden but when i hidden one column ...when i click view that hidden field not showing.. i want to see the view the field that field not showed in the grid view – manasvi Dec 11 '13 at 09:08
  • @manasvi if that is the case what error do u get. please give details – Wahab Dec 12 '13 at 05:11
  • i didnt get any error but not removed in the grid ..what ever i want remove field.i put beforeshowform in colmodel one field but it's displayg again – manasvi Dec 12 '13 at 07:30
  • thanks for ur reply,,,,written some code see my code above i edited ..Please reply – manasvi Dec 14 '13 at 05:29
  • @manasvi i hav created a small working demo which i updated in my answer – Wahab Dec 16 '13 at 10:59