Forum
Topic RSS
04:59
10/08/2009
OfflineHi Guys
I really hope someone can point me out please?
I am trying to bind a json response from a ASP.Net2 Webservice however I am having very little success, I have the following code, which I have seen from another forum post that the guy managed to get to work. What it is doing is going out to the webservice to get a response, on success use the addJSONData to add it to the grid. However what is happening is that I am getting a $.jqGrid.stripHTML error and nothing is being bound to the grid.
The JSON response I am getting from the webservice is
{"d":{"__type":"jqGridData","total":"1","page":"1","records":"1","rows":[{"id":"1","cell":["45","5","140"]},{"id":"2","cell":["45","5","140"]},{"id":"3","cell":["45","5","140"]}]}}
When I run this through an online parse it looks fine, the only thing I feel it could be is that jqGrid does not
know what to do with the __type field. Is this a correct assumption? The rest of the response
seems to match what the specification says.
I have tried to manually use this with jsonstring and jsonstr params, but I get a $.jqgrid.parse error then.
I feel all the pieces are in place, but something isnt quite correct, I'm not interested in paging the data, so just want
something to display my data.
Any help would be appreciated.
$("#history").jqGrid({
datatype: function(){$.ajax({
url: "EmissionsDataHandler.asmx/LoadUserTest",
data: JSON.stringify({username:"Test"}),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
complete: function(jsondata, stat) {
if (stat == "success") {
data = JSON.parse(jsondata.responseText).d
$("#history")[0].addJSONData(data)
}
}
});
}
,
colNames:['ID', 'Annual Leave', 'Known Emissions','Commuting Days'],
colModel:[{name:'Id',index:'Id',width:250},
{name:'AnnualLeave',index:'AnnualLeave',width:250},
{name:'KnownEmissions',index:'KnownEmissions',width:100},
{name:'CommutingDays',index:'CommutingDays',width:100},
],
rowNum: 10,
viewrecords: true,
caption: "Commuting History",
width: 600,
height: 200,
});
06:11
Moderators
30/10/2007
OfflineHello,
Correct first these errors and try:
colModel:[{name:'Id',index:'Id',width:250},
{name:'AnnualLeave',index:'AnnualLeave',width:250},
{name:'KnownEmissions',index:'KnownEmissions',width:100},
{name:'CommutingDays',index:'CommutingDays',width:100}, <----- Error
]
You shoulds not have this here:
.....
rowNum: 10,
viewrecords: true,
caption: “Commuting History”,
width: 600,
height: 200, <---------- This too
});
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.
08:16
10/08/2009
OfflineUpdate:
I finally managed to get the grid to render, I didnt realise the order that the jsgrid.js and locale.js files needed to be put in a specific order, therefore by putting locale infront of jsgrid it appears to be working.
Tony, thanks again for pointing those commas out to me, they obviously were going to be a problem 🙂
Most Users Ever Online: 994
Currently Online:
21 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66
Log In
Home

