I'm working with jqGrid and currently I'm having some issues, mainly because of the config for it.
Currently I want to do this:
var tableConfigJson = $treeTable.getMappedJson();
jQuery(function() {
jQuery("#grid").jqGrid(tableConfigJson);
});
$treeTable is my object on my server side that I am retrieving with velocity mapping.
Now the JSON that I'm getting from my server is fine, however when I pass it to jqGrid to setup the config for it, it doesn't work. If I set up the config in the javascript but I create the config as a javascript object it works fine, however if I just pass the JSON as the config it doesn't work. Now my question is, is there an easy way to get around this? Or am I going to need to map the config again using the JSON.
if I however do this:
jQuery(function() {
jQuery("#grid").jqGrid({
treeGrid: true,
treeGridModel: 'adjacecncy',
ExpandColumn: 'name',
datatype: "local",
mtype: 'Get',
colNames: ['id','Name','MenuId','Menu Name'],
colModel: [
{name:'RowId',index:'RowId',width:300,fixed:true},
{name:'Name',index:'Name',width:300,fixed:true},
{name:'MenuId',index:'MenuId',width:300,fixed:true},
{name:'MenuName',index:'MenuName',width:300,fixed:true},
],
root:[
{id:"1",Name:"Main Menu", MenuId:"1",MenuName:"Menu1"},
{id:"2",Name:"Main Menu1",MenuId:"2",MenuName:"Menu2"},
{id:"3",Name:"Main Menu2",MenuId:"3",MenuName:"Menu3"}
],
pager: '#dvtreegridsamp',
Caption: 'example'
)};
Then it works.
UPDATE:
This is the output in the console for my object, but I think I know what the problem might be now.
Object {datatype: "local", data: Array[3], colNames: Array[2], colModel: Array[2], height: "auto"…}ExpandColumn: "id"
caption: "I am SAD"
colModel: Array[2]0: Object1: Objectlength: 2__proto__: Array[0]colNames: Array[2]
data: Array[3]
datatype: "local"
height: "auto"
sortname: "id"
treeGrid: "true"
treeGridModel: "adjacency"
treedatatype: "local"
The problem is that the parameters that are used for config, are parsed as array objects in places, and not JSON style strings. So these parameters are being ignored. I need these to be JSON style and then everything works.
If I need to clarify anything just let me know, its late and I've had lots of coffee.
console.log()calls to see what's going on? IstableConfigJsonreally an object or is it a string?tableConfigJsonto my function is that it works but only sort of. It doesn't set all of the configs and I'm assuming its because they are double quoted unlike normal java objects which use single quotes.