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
django and Jqgrid issue
27/11/2008
16:33
Avatar
ashish
Member
Members
Forum Posts: 5
Member Since:
28/11/2008
sp_UserOfflineSmall Offline

I am trying to use jqgrid and it does not like the data format my django view is returning. Please help.

json data:

{total:"1", page:"1", records:"2", rows: [[id:18, cell:["status": "New", "due_date": "11/20/08", "task_type": "Defect", "severity": "Medium", "estimated_effort": 35, "task_no": 18, "task_summary": "backlog defect", "sprint_id": 3, "actual_effort_so_far": 5, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": 30, "id": 18]],[id:27, cell:["status": "New", "due_date": "11/21/08", "task_type": "Defect", "severity": "High", "estimated_effort": null, "task_no": 27, "task_summary": "what apain", "sprint_id": 3, "actual_effort_so_far": 0, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": null, "id": 27]]]}

javascript:

here is the js. I see the header and footer of grid but no data

jQuery(document).ready(function(){
  jQuery("#list").jqGrid({
    url:'/viewalltasks/',
    datatype: 'json',
    mtype: 'POST',
    colNames:['Id','Task', 'Status','Owner','Due Date'],
    colModel :[
      {name:'task_no', index:'task_no', width:55},
      {name:'task_summary', index:'task_summary', width:90},
      {name:'status', index:'status', width:80, align:'right'},
      {name:'owner', index:'owner', width:80, align:'right'},
      {name:'due_date', index:'due_date', width:80, align:'right'}],
    pager: jQuery('#pager'),
    jsonReader:{
  root: "row",
  page: "page",
  total: "total",
  records: "records",
  repeatitems: false,
  id: "id"
},
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'id',
    sortorder: "status",
    viewrecords: true,
    imgpath: 'themes/basic/images',
    caption: 'My first grid'
  });
});

28/11/2008
02:43
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I think you should configure jsonReader for this purpose and change

a little the returned data:

Try this

jsonReader: {

root : "rows",

repeatitems : false,

id: "id"

}

configure the jsonmap in the colModel and then return this:

{total:”1″, page:”1″, records:”2″,  rows: [ [ id:18 ,"status": "New", "due_date": "11/20/08", "task_type": "Defect", "severity": "Medium", "estimated_effort": 35, "task_no": 18, "task_summary": "backlog defect", "sprint_id": 3, "actual_effort_so_far": 5, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": 30, "id": 18 ], ....]

Also refer to docs how to configure this

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

28/11/2008
11:12
Avatar
ashish
Member
Members
Forum Posts: 5
Member Since:
28/11/2008
sp_UserOfflineSmall Offline

I tried all that , still no data, it shows the header and footer of grid and loading message but no data,

I added jsonmap, tried with id="0" and id="id" , I am doing some simple mistake... Is there a way to debug on client side why jqgrid does not like what I am sending..

Here is my jqgrid js , followed by data

jQuery(document).ready(function(){ 

  jQuery("#list").jqGrid({

    url:'/viewalltasks/',

    datatype: 'json',

    mtype: 'POST',

    colNames:['Id','Task', 'Status','Owner','Due Date'],

    colModel :[ 

      {name:'id', index:'id',jsonmap:'id', width:55}, 

      {name:'task_no', index:'task_no',jsonmap:'task_no', width:55}, 

      {name:'status', index:'status', jsonmap:'status', width:80, align:'right'}, 

      {name:'owner', index:'owner', jsonmap:'owner',width:80, align:'right'}, 

      {name:'due_date', index:'due_date', index:'due_date',jsonmap:'due_date',width:80, align:'right'}], 

    pager: jQuery('#pager'),

    jsonReader:{

        root: "rows",

        repeatitems: false,

        id: "id"

    },

    rowNum:5,

    rowList:[5,10,20],

    sortname: 'id',

    sortorder: 'asc',

    viewrecords: true,

    imgpath: 'themes/basic/images',

    caption: 'My first grid',

    height:210,

    toolbar: [true,'top']

  }); 

}); 

json data

{total:"1", page:"1", records:"2",rows:[[id:18,"status": "New", "due_date": "11/20/08", "task_type": "Defect", "severity": "Medium", "estimated_effort": 35, "task_no": 18, "task_summary": "backlog defect", "sprint_id": 3, "actual_effort_so_far": 5, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": 30],[id:27,"status": "New", "due_date": "11/21/08", "task_type": "Defect", "severity": "High", "estimated_effort": null, "task_no": 27, "task_summary": "what apain", "sprint_id": 3, "actual_effort_so_far": 0, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": null]]}

28/11/2008
11:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

I'm very sorry for this - it is docs bug - you should  set this way

{total:”1″, page:”1″, records:”2″,rows:[ { id:18,"status": "New", "due_date": "11/20/08", "task_type": "Defect", "severity": "Medium", "estimated_effort": 35, "task_no": 18, "task_summary": "backlog defect", "sprint_id": 3, "actual_effort_so_far": 5, "milestone": "Test Iteration", "owner": "R barron", "open_date": "11/09/08", "effort_remaining": 30 }...]

See the bolded symbols

It will be corrected as soon as possible.

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

28/11/2008
13:06
Avatar
ashish
Member
Members
Forum Posts: 5
Member Since:
28/11/2008
sp_UserOfflineSmall Offline

Thanks,using [] instead of {} was the problem. It is working now. Please get the docs fixed as I changed {} to [] to match the docs.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
72 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