With Named Values

When using json data with named values (i.e the repeatitems option is false) we can use so named dot notation and index notation.

For example, our colModel definition might be as follows:

colModel:[ {name:'name',label:'Name', width:150,editable: true}, {name:'id',width:50, sorttype:"int", editable: true,formatter:strongFmatter}, {name:'email',label:'Email', width:150,editable: true,formatter:'email'}, {name:'stock',label:'Stock', width:60, align:"center", editable: true,formatter:'checkbox',edittype:"checkbox"}, {name:'item.price',label:'Price', width:100, align:"right", editable: true,formatter:'currency'}, {name:'item.weight',label:'Weight',width:60, align:"right", editable: true,formatter:'number'}, {name:'ship',label:'Ship Via',width:90, editable: true,formatter:'select', edittype:"select", editoptions:{value:"2:FedEx;1:InTime;3:TNT;4:ARK;5:ARAMEX"}}, {name:'note',label:'Notes', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ]

Note the elements defined as name:'item.price' and name:'item.weight'

Then our data:

{"page":"1","total":2,"records":"13", "rows":[ {id:"12345",name:"Desktop Computers",email:"josh@josh.com",item:{price:"1000.72", weight:"1.22"},note:"note",stock:"0",ship:"1"}, {id:"23456",name:"<var>laptop</var>",note:"Long text ",stock:"yes",item:{price:"56.72", weight:"1.22"},ship:"2"}, {id:"34567",name:"LCD Monitor",note:"note3",stock:"true",item:{price:"99999.72", weight:"1.22"},ship:"3"}, {id:"45678",name:"Speakers",note:"note",stock:"false",ship:"4"} ] }

Note how item is defined. This data will be intelligently interpreted from the grid.


  Last Updated: 2/7/2009 | © Tony's jqGrid - a jQuery Plugin, 2010