Grid json loading error


We have encountered some issues using grid v3pro. It is parsing json data correctly but when using .load method, passing ‘json’ as data type fails. We have found bug and fixed it, can this be applied to furter versions?

dhtmlXGridObject.prototype._process_json = function (a) { this._parsing = !0; try { a && a.xmlDoc ? eval("a=data=" + a.xmlDoc.responseText + ";") : typeof a == "string" && eval("data=" + a + ";") } catch (b) { dhtmlxError.throwError("LoadXML", "Incorrect JSON", [a.xmlDoc || a, this]), a = { rows: [] } } var c = parseInt(a.pos || 0), d = parseInt(a.total_count || 0), e = !1; (....)

a= was added to eval(“a=data=” + a.xmlDoc.responseText + “;”) as ‘a’ is valid json variable to iterate over, before it was an object used to fetch data.

Thank you.

Thank you for your note. We will investigate it

aambrozkiewicz: What is the error that occurred, perhaps it is the same error I am experiencing “a.rows is undefined” perhaps?

Try this fix and you’ve the answer. :wink:

This fix worked for me.

Without the “fix”, Chrome reported:

And firebug in Firefox reported:

My csharp code was returning (Content-Type: application/json):
{rows:[ {“id”:“0”,“data”:["** No Action Defined **","-","-","-","-"]}] }

The JSON struct is invalid. Correct is:
{“rows”:[ {“id”:“0”,“data”:["** No Action Defined **","-","-","-","-"]}] }

If problem still occurs - try to use the attached versions of js files (43.2 KB) (2.06 KB)

Can you explain what’s fixed?

There was build, where in compressed version of code, part which related to “eval” was compressed incorrectly. ( parsing json string to object was affected )

If you are using latest build - there is no need for update.