I am getting a JSON.parse: unexpected character exception while I am trying to read a local JSON in my JQGrid.
<script type="text/javascript">
var jsondata = {
"totalpages": "1",
"currpage": "1",
"totalrecords": "2",
"invdata" : [
{"name":"New York City", "country":"USA", "continent":"NorthAmerica"},
{"name":"Paris", "country":"France", "continent":"Europe"}
]
};
$(document).ready(function() {
$("#grid").jqGrid({ data: jsondata,
datatype: "json",
colNames: ["Name", "Country", "Continent"],
colModel: [{
name: 'name',
index: 'name',
editable: true,
}, {
name: 'country',
index: 'country',
editable: true,
}, {
name: 'continent',
index: 'continent',
editable: true,
}],
pager: '#pager',
jsonReader : {
root:"invdata",
page: "currpage",
total: "totalpages",
records: "totalrecords",
repeatitems: false,
id: "0"
},
caption:"Dynamic hide/show column groups"
}).navGrid("#pager",{edit:false,add:false,del:false});
jQuery("#hc").click( function() { jQuery("#grid").jqGrid('hideCol',["continent"]); });
jQuery("#sc").click( function() { jQuery("#grid").jqGrid('showCol',["continent"]); });
});
</script>
I have tried to lookup in the jqgrid Wiki but still unable to figure out what's wrong. Is there a problem with the jsonReader? I have checked related questions but it didn't help much.