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
Grid not displaying JSON data
22/03/2013
08:42
Avatar
Seawinnie
Member
Members
Forum Posts: 3
Member Since:
22/03/2013
sp_UserOfflineSmall Offline

Hi,

I am trying to load json data in jqgrid but no data is being displayed. I have confirmed that the HRDatahandler.asp page returns json data. I am a jqgrid newbie and any help is appreciated.

Server side:

HRDataHandler code:

<%@ Language=VBScript %>

<% Response.AddHeader "Content-Type", "application/json"

QueryToJSON(dbconn,"SELECT TOP 500 Id,SkillName,SkillDescription,active,ISNULL(CompletionPlusYears,0) AS CompletionPlusYears,ISNULL(Reminder,'No') AS Reminder,ISNULL(ProjectID,0) AS ProjectID FROM dbo.HR_Skills").Flush Response.End

%>

Client side code:

$(function(){

$("#list").jqGrid({

url:'HR_Datahandler.asp',

datatype: "json",

colNames:['Id','SkillName', 'SkillDescription','active','CompletionPlusYears','Reminder','ProjectID'],

colModel:[

{name:'Id', index:'Id', width:55, key:true},

{name:'SkillName', index:'SkillName', width:150},

{name:'SkillDescription', index:'SkillDescription', width:200, align:'right'},

{name:'active', index:'active', width:80, align:'right'},

{name:'CompletionPlusYears', index:'CompletionPlusYears', width:150, sortable:false},

{name:'Reminder', index:'Reminder', width:80, align:'right'},

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

height:'auto',

pager: '#pager',

rowNum:10,

rowList:[25,50,100],

sortname: 'SkillName',

sortorder: "desc",

viewrecords: true,

gridview: true,

caption: "Skills Grid"

});

});

$("#list").jqGrid('navGrid','#pager',{edit:false,add:false,del:false});

<div id="pager" name="pager"></div> 

<table id="list" name="list"><tr><td/></tr></table> 

ThanksFrown

22/03/2013
08:55
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I am not sure which JSON data produce your code. I recommend you to read documantation about jsonReader especially about root and repeatitems properties of jsonReader. Thy to add jsonReader option in the following form:

jsonReader: {root: function (obj) {return obj;}}

If you will have no success you should include the exact response of server (the JSON data).

Best regards
Oleg 

25/03/2013
01:15
Avatar
Seawinnie
Member
Members
Forum Posts: 3
Member Since:
22/03/2013
sp_UserOfflineSmall Offline

SmileThanks very much Oleg,

All working now.

I was missing the json reader definition:

jsonReader: {
    repeatitems: false,
    id: "Id",
    root: function (obj) { return obj; },
    page: function (obj) { return 1; },
    total: function (obj) { return 1; },
    records: function (obj) { return obj.length; }
}

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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