1

I'm using jqgrid to access a tastypie API. I've changed sidx to "order_by" to match the default tastypie API.

Jqgrid passes the order_by (formerly sidx) get parameter regardless of whether it's ordering by something or not. If it is not sorting, it just passes an empty string as the sort critiera. tastypie freaks out at an empty string saying that "There is no field named '' "

The way I see it, there's two options to solve:

  1. Have jqgrid stop sending the order_by param unless it needs to
  2. Have tastypie ignore an empty order_by string...

Any suggestions on how to do either of those two things?

Jonathan
  • 3,464
  • 9
  • 46
  • 54

1 Answers1

1

I am not sure, that I full understand the problem. First of all to rename sidx to order_by one can use

prmNames: {sort: "order_by"}

If you never will that sidx or order_by will be send you can use

prmNames: {sort: null}

You can implement some scenarios in changing the prmNames.sort dynamically. You can use jqGrid callbacks or events.

One more way to control the list of parameters which will be sent to the server is serializeGridData callback. For example

serializeGridData: function (postData) {
    var myPostData = $.extend({}, postData); // make a copy of the input parameter
    if (myPostData.sidx.length === 0) { // or myPostData.order_by.length
        delete myPostData.sidx;
    }
    return myPostData;
}

See the answer for another example.

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