1

I've tried to use remapColumns:

grid.remapColumns(newOrder, false, false);

but got a strange issue - column headers was reordered, but column infos stayed untouched. How can solve that?

EDIT:

Whole mthod

permutateGrid: function (gridID, columnsToShow, columnsToHide) {
    var newOrder = [];
    var grid = $(gridID);

    for (var i = 0; i < columnsToShow.length; i++) {
        newOrder.push(GridHelpers.getColumnSrcIndexByName(grid, columnsToShow[i]));
    }

    var columnsCount = grid.jqGrid("getGridParam", "colModel").length;
    for (var i = 0; i < columnsCount; i++) {
        if (newOrder.indexOf(i) === -1) {
            newOrder.push(i);
        }
    }

    showColumns(gridID, columnsToShow);
    hideColumns(gridID, columnsToHide);

    grid.jqGrid('remapColumns', newOrder, false, false);
    grid[0].jqGrid().updateColumns();
},
skayred
  • 10,603
  • 10
  • 52
  • 94
  • What you mean under "column infos"? What exactly is wrong? Do you use `newOrder` array which has the same length as `colModel`? – Oleg Feb 25 '13 at 07:40
  • Column infos is a column contents. `newOrder` has the same lengths as 'colModel', see EDIT – skayred Feb 25 '13 at 07:43
  • which version of jqGrid you use? I don't know `updateColumns`. It doesn't exist in jqGrid now. Moreover I still don't understand what problem you have. What is "column contents"? Do you mean the column headers of the columns of the grid? When and where you call `permutateGrid` function (for example in empty grid, inside of some callback etc) – Oleg Feb 25 '13 at 07:54
  • I removed `updateColumn` string because there is no such function. I'm using jqGrid version 4.4.1. I'm calling `permutateGrid` from callback for grid with some information, and then calling 'reloadGrid'. And the problem is following: ONLY column HEADERS are reordered after these actions. – skayred Feb 25 '13 at 07:59
  • @Oleg: the wiki (http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods) still lists the updateColumns method, that's probably where the confusion is coming from. See also this question (http://stackoverflow.com/questions/18191543/how-to-fix-sync-issue-between-column-header-width-and-column-body-width-without) and this post on the jqGrid forum (http://www.trirand.com/blog/?page_id=393/help/updatecolumns-deprecated-in-3-8-is-there-a-replacement-to-fix-header-widthing-issue-1/#p29770), which led me here. – mcw Oct 30 '13 at 19:11
  • @mcw0933: Sorry, I'm not sure what you mean. If you have some suggestion how to improve wiki documentation of jqGrid you can do this like every other person. You need just register on the wiki and make the changes which you mean should be done. The owner of the wiki (trirand and not me) can revert the changes or improve there. I have no relation to trirand. [Your post](http://www.trirand.com/blog/?page_id=393/help/updatecolumns-deprecated-in-3-8-is-there-a-replacement-to-fix-header-widthing-issue-1/#p29770) seems to me describes **absolutely another problem**. – Oleg Oct 30 '13 at 19:19

1 Answers1

2

The second parameter of remapColumns should be true if you want to update grid content. Typical usage of remapColumns is grid.jqGrid("remapColumns", newOrder, true, true); (or grid.remapColumns(newOrder, true);).

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Is that ethod suitable for grid with subgrids? – skayred Feb 25 '13 at 08:21
  • My problem was following - I've tryed to remap all the column including `subgrid` - but it have to stay at `0` index – skayred Feb 25 '13 at 08:31
  • @skayred: I would recommend you to include screenshort next time. It would clear many things. Additionally more full JavaScript code with jqGrid parameters are required in the most cases. – Oleg Feb 25 '13 at 08:41