Author Topic: How to hide and enable column header  (Read 3172 times)

Ajay

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 31
    • View Profile
How to hide and enable column header
« on: July 28, 2016, 04:21:07 pm »
I am using paramquery pro 3.1.0 version.
Here is my pq grid intilisation code:

searchOrgGrid = $('#gridSearchOrgs');
                var columnModel = [{ title: "", dataIndx: "UID", hidden: true, width: 100, align: "left" },
                                   {
                                       title: nmc.platform.strings.Name, dataIndx: "Name", width: 200, align: "left",
                                       dataType: function (val1, val2) {
                                           return NMCApp.stringSort(val1, val2);
                                       }
                                   },
                                   {
                                       title: nmc.platform.strings.OrganizationId, dataIndx: "Id", width: 300, align: "left",
                                       dataType: function (val1, val2) {
                                           return NMCApp.stringSort(val1, val2);
                                       }
                                   },
                                   {
                                       title: nmc.platform.strings.InstitutionCode, dataIndx: "InstitutionCode", width: 200, align: "left",
                                       dataType: function (val1, val2) {
                                           return NMCApp.stringSort(val1, val2);
                                       }
                                   },
                                  {
                                      title: nmc.platform.strings.PartnerName, dataIndx: "PartnerName", editable: false, width: 100, align: "left", dataType: function (val1, val2) {
                                         return NMCApp.stringSort(val1, val2);
                                     }
                                 }];
                             
                       
                searchOrgGrid.pqGrid({
                    width: NMCApp.getSearchGridWidth(),
                    height: NMCApp.getSearchGridHeight(),
                    editable: false,
                    showTop: false,
                    showBottom: false,
                    numberCell: false,
                    roundCorners: false,
                    wrap: false,
                    colModel: columnModel,
                    dataModel: { data: [] },
                    hoverMode: 'row',
                    selectionModel: { type: 'row', mode: 'single' },
                    virtualY: true,
                    virtualX: true,                 
                   
                    refresh: function (evt, ui) {
                        var $grid = $(this),
                           virtualY = $grid.pqGrid('option', 'virtualY'),
                           length = $grid.pqGrid('pageData').length,
                           val = (length > 50) || (length == 0);//any cutoff number in place of 20

                        if (val !== virtualY) {
                            $grid.find(".pq-sb-vert").pqScrollBar("option", "steps", val);
                            $grid.pqGrid('option', 'virtualY', val).pqGrid('refresh');
                        }
                    }
                });

                if (NMCApp.hasGlobalGrant(nmc.platform.grants.ManagePartners, false)) {
                    columnModel[6].hidden = false;
                    searchOrgGrid.pqGrid("option", "colModel", columnModel);
                }

I am trying to hide 'partnername' column based on the condition,the condition is executing but still the column is visible.

I am not sure what is the issue.

Ajay

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: How to hide and enable column header
« Reply #1 on: July 28, 2016, 04:44:01 pm »
I got the solution:

 if (NMCApp.hasGlobalGrant(nmc.platform.grants.ManagePartners, false)) {
                    var colM = searchOrgGrid.pqGrid("option", "colModel");
                    colM[6].hidden = false;
                    searchOrgGrid.pqGrid("option", "colModel",colM);
                }