Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
JSON Data problem
30/06/2009
07:40
Avatar
mbanaouas
Member
Members
Forum Posts: 6
Member Since:
30/06/2009
sp_UserOfflineSmall Offline

I'm facing a problem with JSON Data.

I started with jqGrid "Demos Array" (local data) and it works fine.

Now, I would like to move to json callback but the grid shows 'Loading ...' and firebug show this error:

n is undefined

grid.base-min.js :... b.fn.setSelection=function(w,z,q){return this.each(function(){var g=this,m,l,n;z=z===false?false:true;if(w===false){l= ...

I provide "grid_data.txt" file in apache server root folder containing the json data:

{"total": "1","page": "1", "records": "1", "rows" :  [ {"id":"1","invdate":"2007-10-01","name":"test","note":"note","amount":"200.00","tax":"10.00","total":"210.00"}
  ]}

and this is script part of grid_url.html:

<script type="text/javascript">
// We use a document ready jquery function.
jQuery.noConflict();
jQuery(document).ready(function(){
  gridimgpath = "themes/green/images";
  jQuery("#list4").jqGrid({
        datatype: 'json',
        url: 'grid_data.txt',
        mtype: 'GET',
      height: 250,
         colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
         colModel:[
             {name:'id',index:'id', width:60, sorttype:"int"},
             {name:'invdate',index:'invdate', width:90, sorttype:"date"},
             {name:'name',index:'name', width:100},
             {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
             {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
             {name:'total',index:'total', width:80,align:"right",sorttype:"float"},
             {name:'note',index:'note', width:150, sortable:false}
         ],
         pager: jQuery('#pager2'),
         imgpath: gridimgpath,
         multiselect: true,
         caption: "Manipulating Array Data",
      jsonReader : { root: "rows", page: "page", total: "total" , records: "records" }
  });
});
</script>

Any thoughts are appeciated. Regards.

30/06/2009
19:03
Avatar
mbanaouas
Member
Members
Forum Posts: 6
Member Since:
30/06/2009
sp_UserOfflineSmall Offline

the problem is caused by bad data format.

for jqGrid, json data must to be in a special format :

{
  "page":"1",
  "total":1,
  "records":"3",
  "rows":[
    {"id":"1","cell":["1","2009-06-15","CLI-1","75000","5000","80000","cli-1"]},
    {"id":"2","cell":["2","2009-06-08","CLI-2","45000","5000","50000","cli-2"]},
    {"id":"3","cell":["3","2009-06-01","CLI-3","25000","5000","30000","cli-3"]}
  ]
}

Now it works fine !

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
55 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information