Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:01:53+00:00 2026-06-17T19:01:53+00:00

EDIT : Final solution is below. Whether I try to implement column re-ordering via

  • 0

EDIT: Final solution is below.

Whether I try to implement column re-ordering via header dragging or via the column chooser plugin, after re-ordering the columns, clicking on any column header to sort results in the sorted columns being loaded into their original positions in the table. Using the sortable method:

sortable: { 

update: function (perm) {
    /*
     * code to save the new colmodel goes here
    */
    // the following line doesn't seem to do anything... just seems to return an array identical to 'perm'
    $("#mainGrid").jqGrid("getGridParam", "remapColumns");

    // if included, the next line causes the headers to not move
    $("#mainGrid").jqGrid("remapColumns", perm, true); 

    // this alternate allows them to move, but the newly sorted columns still get remapped to their original position
    $("#mainGrid").jqGrid("remapColumns", [0,1,2,3,4,5,6,7,8,9,10,11,12], true);

    /* the following allows the headers to move, and allows the sort to occur ONLY
     * if the order coming back from the database is unchanged. Note that in my real
     * code I create an array of consecutive integers to pass as the first param to
     * remapColumns()
     */
    $("#mainGrid").jqGrid("remapColumns", [0,1,2,3,4,5,6,7,8,9,10,11,12], true, false);
}
}

When the page is reached for the first time, it creates a default column model from an xml file. When the user re-orders the headers, the new column model and column names are stored in the database as JSON strings. When the user makes another database call, the function reads the new column order from the database and creates the data array with the new ordering.

The problem seems to be that after jqGrid has remapped the columns, it still expects to see the data coming back from the server in the original order. So if the original data was

[ [A1, B1, C1], [A2, B2, C2], [A3, B3, C3] ]

after remapping the columns to the order C | A | B, jqGrid still wants the data to came back in the original order.

My final solution was to remove the code that saves the column model state from the sortable.update() function and to put it into window.onbeforeunload(). This way, the state is only saved when the user exits the page.
Hope this helps someone else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:01:54+00:00Added an answer on June 17, 2026 at 7:01 pm

    See edited question. Without a method to update the colModel, the best solution seems to put the state save function into window.onbeforeunload().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

FINAL EDIT (Partial Solution): After a lot of tinkering I've been able to accomplish
FINAL EDIT: After following the answer from Darin Dimitrov, I have found that the
EDIT: The code below has been edited to show the correct solution to the
EDIT: See my answer below--> I am wanting to have a view that when
Suppose I have a table with the column Description, varchar(100). If try to insert
Final update and fix : The solution here turned out to be a combination
I have written the code below to test whether a list is a Palindrome
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,
Edit (updated question) I have a simple C program: // it is not important

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.