Using jqGrid with Fusion Tables, if the JSON returns with results it works fine, but if there are no results then because obj.rows doesn't exist, the page breaks when trying to check the length. Is there a way to handle this gracefully?
jsonReader: {
cell: "",
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.rows.length; }
},
Uncaught TypeError: Cannot read property 'length' of undefined
and the JSON:
// API callback
jQuery16405104181477800012_1369220882365({
"kind": "fusiontables#sqlresponse",
"columns": [
"id",
"latitude",
"longitude",
"name",
"address_line_1",
"address_line_2",
"address_line_3",
"postcode"
]
}
);
and below is an example of a result with rows:
jQuery1640010438381228595972_1369222778703({
"kind": "fusiontables#sqlresponse",
"columns": [
"id",
"latitude",
"longitude",
"name",
"address_line_1",
"address_line_2",
"address_line_3",
"postcode"
],
"rows": [
[
"1132584",
50.55307,
"-4.19639",
"The Road",
"ROAD",
"Town",
"CITY",
"POSTCODE"
],