0

I read all the posts regarding freezing column. But still I am unable solve my problem.

When I called setFrozenColumns my column has frozen but along with another column header is added to the grid. So the column headers one more than the columns. How to resolve this. Here is my over view of code.

makeJqueryGridInstance(grid, gridSettings);
window.prepareSortableColumns(grid);

makefrozenColumns(grid);

function makeFrozenColumn( grid ) 
{
    var colmodel = grid.jqGrid('getGridParam', 'colModel');
    if (colmodel[0].name === 'cb') 
        {
            grid.jqGrid('setColProp', colmodel[0].name, { frozen: true });
            grid.jqGrid('setFrozenColumns');
            fixPositionsOfFrozenDivs.call(grid[0]);
        }
}

function prepareSortableColumns(grid) 
{
    var gridSettings = grid.data('settings');
    var gridId = gridSettings.gridId;
    var columnHeaders = $("#" + "gview_" + gridId.replace("#", "")).find(".ui-jqgrid-htable > thead > tr > th");
    var colModel = grid[0].p.colModel;
    $.each(columnHeaders, function (index, columnHeader) 
    {
        if (colModel[index].sortable == false) 
        {
            $(columnHeader).find("div").removeClass("ui-jqgrid-sortable");
        }
    });
 }

For the first time, it is working fine and the column has frozen.

But second time when the call made to prepareSortableColumns(grid), the columnHeader having one more than colModel (I debugged through devTools). So I am getting error for that particular columnHeader sortable is undefined.

Can anybody help me with this. Thanks in advance.

trinadh
  • 258
  • 4
  • 14

1 Answers1

0

The code of prepareSortableColumns seems be wrong. Its not oriented on dives added in case of usage of frozen columns (see the answer for more details and use Developer Tools to examine the structure of the grids). You can try to use grid[0].grid.headers array instead of selecting columnHeaders in the way like you do this.

Additionally it's in general wrong to remove ui-jqgrid-sortable class. The meaning of the class will be frequently misunderstood because of the name. Non-sortable columns have to have the class too. What you need to do instead is to set CSS style cursor: default on the headers. See the old answer for the corresponding code example.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798