jQuery UI Widgets › Forums › Grid › Grid say no data to display while loading json from webservice
Tagged: data, grid, jqxgrid, json, load, populate, record, source, web service, webservice
This topic contains 4 replies, has 2 voices, and was last updated by Dimitar 9 years, 11 months ago.
-
Author
-
Hi
When i’m loading json from a Service, parsing it to an Array and using datatype: ‘array’, it works fine.
When i’m using datatype: ‘json’ and a URL, the data would not be displayed.
=> the data is, in my opinion, correctly loaded from the Server.My case: (the dedinitions fro datafields and columns are not copied below)
– Javascript –
var pars = new JsonParamList(‘ANTRAS.Common.Business.User’, ‘SelectAll’);
pars.add(new JsonParam(‘rnp’, false));
pars.add(new JsonParam(‘SessionId’, userSessionState.getSessionId()));
var url = ‘/ANTRAS.Common.Web/Ajax/Handler.asmx/Service’;
source =
{
datatype: “json”,
datafields: datafields,
id: ‘Id’,
record: “User”,
root: “Payload”,
url: url,
type: ‘POST’,
data: { jsonParamObject: function () { return pars.toJson() }, payLoadJson: ” }
};dataAdapter = new $.jqx.dataAdapter(source, {
downloadComplete: function (data, status, xhr) { },
mapChar: ‘.’,
loadComplete: function (data) { },
// Test: the data is correct displayed
downloadComplete: function (data) { alert(data.Payload[0].Name); },
loadError: function (xhr, status, error) { alert(‘loadError’); }
});$(“#” + this._widgetId).jqxGrid(
{
width: ‘100%’,
height: ‘700px’,
source: dataAdapter,
columnsresize: true,
theme: ‘energyblue’,
columnsheight: 20,
autoheight: false,
rowsheight: 20,
columns: propCol
});– json –
{
“CurrentLang”: “DE”,
“IsLoggedIn”: false,
“UserId”: “”,
“ResultState”: “Successful”,
“Payload”: [
{
“IsDeletable”: false,
“Email”: “user1@test.com”,
“ReceiveStatistics”: “Y”,
“Language”: {
“IsDeletable”: true,
“Iso”: “DE”,
“Title”: “Deutsch”,
“Active”: “Y”,
“Default”: “N”,
“MultilangList”: [],
“Description”: null,
“Id”: 40,
“IsNew”: false,
“IsGlobalObject”: true,
“IsCached”: true
},
“MemberCondition”: {
“Title”: “Bestätigt vom Admin”
},
“MultilangList”: [
{
“IsDeletable”: true,
“Lang”: “DE”,
“Field”: “desc”,
“Text”: null,
“Id”: 112900,
“IsNew”: false,
“IsGlobalObject”: false,
“IsCached”: false
},
{
“IsDeletable”: true,
“Lang”: “DE”,
“Field”: “title”,
“Text”: null,
“Id”: 112901,
“IsNew”: false,
“IsGlobalObject”: false,
“IsCached”: false
}
],
“Title”: null,
“Description”: null,
“Id”: 1121,
“IsNew”: false,
“IsGlobalObject”: true,
“IsCached”: false
},
{
“IsDeletable”: false,
“Name”: “User 2”,
“Email”: “user2@test.com”,
“ReceiveStatistics”: “Y”,
“Language”: null,
“MemberCondition”: {
“Title”: “Bestätigt vom Admin”
},
“MultilangList”: [
{
“IsDeletable”: true,
“Lang”: “DE”,
“Field”: “desc”,
“Text”: null,
“Id”: 112905,
“IsNew”: false,
“IsGlobalObject”: false,
“IsCached”: false
},
{
“IsDeletable”: true,
“Lang”: “DE”,
“Field”: “title”,
“Text”: null,
“Id”: 112906,
“IsNew”: false,
“IsGlobalObject”: false,
“IsCached”: false
}
],
“Title”: null,
“Description”: null,
“Id”: 1173,
“IsNew”: false,
“IsGlobalObject”: true,
“IsCached”: false
}
]
}Hello tm@antras.ch,
When you are running your page is “loadError” alerted? If so, please share what is the error thrown by the loadError callback (passed in the error parameter).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar
> When you are running your page is “loadError” alerted?
> If so, please share what is the error thrown by the loadError callback (passed in the error parameter).
No.
Instead the method
downloadComplete: function (data) { alert(data.Payload[0].Name); },
will be fired with the correct data!
So it seams (also according the result of the webrequest in firebug), that
the Service is called and the Response is what it should.Regards,
ThomasHi All
I’v figured it out.
After removing the line form the source object Definition:
> record: “User”,The data was displayed.
For me, the docu wasn’t clear:
http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-datasources.htm
•record: A string describing the information for a particular record.
What exactly is the property ‘record’ for?Regards,
ThomasHi Thomas,
In the following sample XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <Customers> <Customer CustomerID="1" Name="Customer 1"></Customer> <Customer CustomerID="2" Name="Customer 2"></Customer> </Customers>
each Customer tag shows information about a particular customer (record). Thus, the field record has to be set to “Customer” in the source definition:
var source = { datatype: "xml", datafields: [ { name: 'CustomerID', map: '[CustomerID]' }, { name: 'Name', map: '[Name]' } ], root: "Customers", record: "Customer", url: url };
There are more examples in the aforementioned help topic and in the demo section, too. These may help you better understand the source object and its fields.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.