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

  • SEARCH
  • Home
  • 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 8720205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:58:56+00:00 2026-06-13T06:58:56+00:00

I have problem with jqGrid plugin. If I am on e.g. 2nd page, and

  • 0

I have problem with jqGrid plugin. If I am on e.g. 2nd page, and I want to change the sorting direction of any column, to the server goes as a URL param page=1 (but should be page=2) What’s wrong ?

<table id="list" class="scroll " cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>
$(function () {

    $("#list").jqGrid({
        url: '/Control/UsersGridData/',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Name', 'User ID', 'Is Active', 'Last Action',  'Country'],
        colModel: [
  { name: 'Name', index: 'Name', width: 120, align: 'center', sortable: true, search: true },
  { name: 'UserID', index: 'UserID', width: 120, align: 'center', sortable: true, search: true },
  { name: 'IsActive', index: 'IsActive', width: 50, align: 'center', sortable: true, search: true },
  { name: 'LastAction', index: 'LastAction', width: 90, align: 'center', sortable: true, search: true },
  { name: 'Country', index: 'Country', width: 40, align: 'center', sortable: true, search: true }],
        pager: jQuery('#pager'),
        rowNum: 20,
        rowList: [5, 10, 20, 50],
        sortname: 'Name',
        sortorder: "desc",
        viewrecords: true,
        imgpath: '/scripts/themes/coffee/images',
        width: '800'
    });
});
  • 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-13T06:58:57+00:00Added an answer on June 13, 2026 at 6:58 am

    The page number will be explicitly changed (see the line of code sortData function used inside of click event handler on the column header).

    You can change the value inside of onSortCol event handler for example. You can get the value of current page directly from the corresponding <input> filed of pager: $(pagerIdSelector).find("input.ui-pg-input").val() where var pagerIdSelector = $(this).jqGrid("getGridParam", "pager").

    In my opinion resetting the pager value to 1 is correct behavior. Let us you have some grid with 20 pages and the data are sorted by the first column in “asc” order. If the second page are displayed and the user clicks on the first column. In the case the sort order should be inverted to “desc”. In the case the page number of the current page will be about 18 (it’s 18 only if all pages are full with rows). If the user click on any other column and the grid should be sorted by another column then the rows displayed on the current page could have any location on the 20 pages sorted by the new criteria. Because of that jqGrid reset the value of page to 1 on every sorting of grid.

    UPDATED: Some additional remarks to your code which are not important to your main question:

    • jqGrid replaces pager: jQuery('#pager') to pager: '#pager' during initializing time. So it has no seance to make unneeded search of element by id. One should better always use id-selector syntax for pager option.
    • imgpath option id deprecated and it will be just ignored by jqGrid. So you should remove it.
    • In the same way you call reduce HTML fragment needed for jqGrid to <table id="list"></table><div id="pager"></div>. All other attributes are deprecated and will be not used by jqGrid.
    • The properties sortable: true, search: true are default (see the documentation) and one should remove it. In the same way if you use index with the same value as name you can remove definition of index property. If you want use align: 'center' in the most of your columns you can reduce and simplify your code if you would change the default value for the align property. After the usage of cmTemplate: {align: 'center'} option of jqGrid (see here for more information) you can remove align: 'center' in all columns. After all the changes the definition of all items of colModel will be short and clear like { name: 'Name', width: 120 }.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this mysql tables I want to display with jqgrid. The problem appears
Is there any way to disable jqgrid local cache??? I have a page which
I have a JSP page with multiple instances of a jqGrid. One column of
Greetings, I have a problem using jqgrid and jquery tab (I am coding in
I'm using jqGrid and I have a problem getting Dynamic Linq to work. I
I have problem with UIWebView delay when the load image from url. In my
I have a problem with the jqgrid Date formatter. in my DB table i
I'm using jqgrid for which I create column definitions on server as dynamic objects
I have a problem how to make a default search based on Ship_via Column
I have a strange problem with my sopt search options in my jqgrid. I

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.