2

I have tried hidden: true, width: 0, display: false but still I see the column in the grid. Than I tried

myGrid.jqGrid('hideCol', ["Type"]);

issue 1:

which is working and column is hidden but once I show collapsed rows than this column is again visible.

issue 2:

I have groupCollapse: true . When I uncollapse and do the sorting than all the rows collapsed again.

Problem:

Collapse/UnCollapse the hidden column shouldn't visible.

When sorting rows collapse.

var myGrid = $('#list');
myGrid.jqGrid({
    url: '/Admin/DynamicGridData/',
    datatype: 'json',
    mtype: 'POST',
    colNames: ['Id', 'Date', 'First Name', 'Last Name', 'Email Address', 'Hidden'],
    colModel: [

                    { name: 'Id', index: 'Id', width: 40, align: "center", editable: false, editoptions: { readonly: true }, key: true, sorttype: "int", searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge']} },
                    { name: 'DateEdited', index: 'DateEdited', width: 90, sorttype: "date", formatter: "date" },
                    { name: 'FirstName', index: 'FirstName', width: 120, searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge']} },
                    { name: 'LastName', index: 'LastName', width: 120, searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge']} },
                    { name: 'Email', index: 'Email', width: 300, searchoptions: { sopt: ['cn', 'nc', 'bw', 'bn', 'eq', 'ne', 'ew', 'en', 'lt', 'le', 'gt', 'ge']} },
                    { name: 'Type', index: 'Type', hidden: true, width: 0, display: false, search: false }

                ],

    height: 'auto',
    autowidth: true,
    rownumbers: true,

    rowNum: 30,
    rowList: [10, 20, 30],
    pager: '#pager',
    sortname: 'Id',
    viewrecords: true,
    sortorder: "asc",
    multiselect: true,
    altRows: true,
    altclass: 'myAltRowClass',
    caption: "Master Grid",
    jsonReader: { cell: "" },

    grouping: true,
    groupingView: { groupField: ['Type'],
        groupColumnShow: [true],
        groupText: ['<b>{0} - {1} Record(s)</b>'],
        groupCollapse: false,
        groupOrder: ['desc']
    }
});
myGrid.jqGrid('navGrid', '#pager', { add: false, edit: false, del: true }, {}, {},

    { },

    { multipleSearch: true, overlay: false });

myGrid.jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: 'cn' });
myGrid.jqGrid('navButtonAdd', '#pager', { caption: "Filter", title: "Toggle Searching Toolbar", buttonicon: 'ui-icon-pin-s', onClickButton: function () { myGrid[0].toggleToolbar(); } });
myGrid[0].toggleToolbar();
myGrid.jqGrid('hideCol', ["Type"]);
Pirzada
  • 4,685
  • 18
  • 60
  • 113

1 Answers1

4

You can use either

myGrid.jqGrid('hideCol', "Type");

instead of myGrid.jqGrid('hideCol', ["Type"]); or use

groupColumnShow: [false]

instead of groupColumnShow: [true] because you want hide the column on which you do grouping.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I understand that. Column is hidden and not showing. But what about collapsing problem when I sort columns. It should not collapse when sorting columns. Any idea? – Pirzada Jul 07 '11 at 13:43
  • @pirzada: On some actions like paging, sorting, filtering jqGrid rebuild the grid contain and so apply the `groupCollapse: true`. So it is not a bug. If you need to save the "collapse" state you can do this inside of [onPaging](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:pager#events) event handler and use `groupingToggle` inside of `loadComplete` to expand the grouping one more time. – Oleg Jul 07 '11 at 15:20
  • @Oleg: Please see [this question](http://stackoverflow.com/questions/6939096/hide-grouping-heading-in-jqgrid-if-every-row-inside-it-is-hidden) – AabinGunz Aug 04 '11 at 11:32
  • @Abhishek Simon: I am busy with my main job. I'll take a look in your question if I'll have time. – Oleg Aug 04 '11 at 12:23