Sequenzia
Sequenzia

Reputation: 2381

Passing array into processing page in jqGrid

I am looking for a little bit of help with jqGrid.

I have a basic grid that uses the options URL to call a function on a page in my model. This function then queries a database and returns data in JSON format and it is presented in the grid.

Very basic and it is working perfect. I am now trying to figure out the best way to send an array of data to the model page from the view where the grid is. This data will then be used for business logic before the query.

I am assuming that I need to convert the array to JSON, send it, and then reconstruct on my model page. I can do that fine but I am not sure how to get the array (in JSON or whatever) to the model page for processing. I can send individual variables by just adding them to the URL but I do not know how to deal with this array of data.

Any help on this matter would be great.

Thanks

Upvotes: 0

Views: 849

Answers (1)

Oleg
Oleg

Reputation: 221997

If you would use JSON.stringify from json2.js (if the browser have native support of the function json2.js will uses it automatically) you would convert array to the string. The string you can send to the server either appending it to the URL (don't forget to call encodeURIComponent or jQuery.param) or you can use postData parameter of jqGrid for example in the form:

postData: {
    myArray: function () { return JSON.stringify(myArray); }
}

Upvotes: 1

Related Questions