1

The bellow is my jqGrid config:

$('#grid').jqGrid({
    url: '/Panel/Article/latest_articles_json',
    datatype: 'json',
    fitWindow: SITE.FITWINDOW,
    postData: {},
    height: $(window).height() - 260,
    width: $(window).width() + SITE.FITWINDOW[0],
    altRows:true,
    gridview: true,
    colNames: colNames,
    colModel: colModel,
    autowidth: true,
    pager: '#page',
    page: 1,
    viewrecords: true,
    rowList: [50,100,200],
    rowNum: 50,
    shrinkToFit:false,
    cmTemplate: {sortable:false},
    jsonReader: {
        root: 'data.items',
        records: 'data.records',
        total: 'data.totalsize',
        page: 'data.page',
        id: 'id'
    }
});

When I run my web application it result with query string parameters it requests as ajax with parameters

_search:false
nd:1460779456815
rows:50
page:1
sidx:
sord:asc

Now I have the question with how I can override the query string of "sord:asc" to change to "sord:desc"

And I am tried to modify the config: url: '/Panel/Article/latest_articles_json?sord:desc', but it doesn't work?

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
Shi Falei
  • 51
  • 4

1 Answers1

0

The values of parameters sord and sidx come from the jqGrid options sortorder and sortname. Thus you should add sortorder: "desc" option to have sord=desc instead of sord=asc.

To control the names and the existence of other default parameters sent to the server one should use prmNames option. For example

prmNames: { nd: null, search: "isSearch" }

removes nd parameter (likend=1460779456815) and to rename _search parameters to isSearch. I recommend to set cache-control: private, max-age=0 as HTTP header (see the answer and this one).

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