Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
wiki:upgrade_from_3.6.4_to_3.6.5 [2010/05/20 13:14] tony |
wiki:upgrade_from_3.6.4_to_3.6.5 [2017/12/12 17:05] (current) admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Upgrade from 3.6.4 to 3.6.5 ====== | ====== Upgrade from 3.6.4 to 3.6.5 ====== | ||
- | You should read this upgrade when you use JSON response from the server.\\ \\ | + | You should read this upgrade notes when you use JSON response from the server.\\ |
+ | These notes are valid when you upgrade from any other version of jqGrid.\\ \\ | ||
- | With version 3.6.5 we switch from ajax complete to ajax success event. This will reflect in certain systems not to display the data. \\ \\ | + | With version 3.6.5 we switch from ajax complete to ajax success event. \\ |
+ | With this switch we directly use the jQuery parsing of JSON data. As of version 1.4.x of jQuery this parsing is strict. More information can be found [[http://api.jquery.com/jQuery.getJSON/ | here]] \\ | ||
+ | This will reflect in certain systems not to display the data. \\ \\ | ||
What you need to know if the data is not displayed when you upgrade from 3.6.4 to 3.6.5 version \\ \\ | What you need to know if the data is not displayed when you upgrade from 3.6.4 to 3.6.5 version \\ \\ | ||
Line 40: | Line 43: | ||
As can be seen every property should be quoted. \\ | As can be seen every property should be quoted. \\ | ||
+ | |||
+ | ===== The "d" Property ===== | ||
+ | Switching from ajax complete to ajax success event causes to skip the jqGrid parse function, which detect automatically the so named "d" property from the response (used in certain systems). \\ \\ | ||
+ | |||
+ | In order to solve the problem the jsonReader should be changed so that it can interpret this property correct. \\ | ||
+ | If the default jsonReader is : | ||
+ | |||
+ | <code javascript> | ||
+ | jQuery("#gridid").jqGrid({ | ||
+ | ... | ||
+ | jsonReader : { | ||
+ | root: "rows", | ||
+ | page: "page", | ||
+ | total: "total", | ||
+ | records: "records", | ||
+ | repeatitems: true, | ||
+ | cell: "cell", | ||
+ | id: "id", | ||
+ | userdata: "userdata", | ||
+ | subgrid: {root:"rows", | ||
+ | repeatitems: true, | ||
+ | cell:"cell" | ||
+ | } | ||
+ | }, | ||
+ | ... | ||
+ | }); | ||
+ | </code> | ||
+ | \\ | ||
+ | |||
+ | It should be changed to | ||
+ | |||
+ | <code javascript> | ||
+ | jQuery("#gridid").jqGrid({ | ||
+ | ... | ||
+ | jsonReader : { | ||
+ | root: "d.rows", | ||
+ | page: "d.page", | ||
+ | total: "d.total", | ||
+ | records: "d.records", | ||
+ | repeatitems: true, | ||
+ | cell: "cell", | ||
+ | id: "id", | ||
+ | userdata: "userdata", | ||
+ | subgrid: {root:"d.rows", | ||
+ | repeatitems: true, | ||
+ | cell:"cell" | ||
+ | } | ||
+ | }, | ||
+ | ... | ||
+ | }); | ||
+ | </code> | ||
+ | |||
+ | Note that the cell property should not be changed | ||
+ | |||
+ | ===== loadComplete changes===== | ||
+ | As of the documentation to the loadComplete event we pass as parameter the request from the response. In most cases to use the request before version 3.6.5 you will need to use the responseText property. \\ | ||
+ | After this change the "response" passed to this event is actually the data from the server converted automatically from jQuery according to the datatype parameter. \\ \\ | ||
+ | By example let suppose that you use json datatype. Before 3.6.5 in order to use the response as object you maybe do the following: \\ | ||
+ | |||
+ | <code javascript> | ||
+ | jQuery("#gridid").jqGrid({ | ||
+ | ... | ||
+ | datatype : "json", | ||
+ | loadComplete : function (request) { | ||
+ | // to convert the request using JSON.parse to JavaScrip object you do maybe this: | ||
+ | var myrequest = JSON.parse(request.responseText); | ||
+ | .... | ||
+ | }, | ||
+ | ... | ||
+ | }); | ||
+ | </code> | ||
+ | |||
+ | After 3.6.4 you should remove JSON.parse -i.e | ||
+ | <code javascript> | ||
+ | jQuery("#gridid").jqGrid({ | ||
+ | ... | ||
+ | datatype : "json", | ||
+ | loadComplete : function (request) { | ||
+ | // no need to use JSON.parse: | ||
+ | var myrequest = request; | ||
+ | .... | ||
+ | }, | ||
+ | ... | ||
+ | }); | ||
+ | </code> | ||