Hi guys,
I am using ASP.NET C# and a WebMethod in code-behind to get the data (json object) from database.
Everything appears to work (json object can be build, but has not a {“data”: at first, it has only the array with the records), but no data appears on the page. The resulting page shows a blank grid with 3 columns and 15 rows.
Why the data is not being rendered to the grid?
Is something I missing in my code?
Should I insert the element {“data”: to json object?
Please help!
Here is a part of the relevant code:
var sourceGrid = {
datatype: “json”,
cache: false,
contentType: ‘application/json; charset=utf-8’,
datafields: [
{ name: ‘Id’, type: ‘string’ },
{ name: ‘Date’, type: ‘date’ },
{ name: ‘Comment’, type: ‘string’ }
],
async: false,
url: ‘Default.aspx/GetData’,
id: ‘Id’,
…
}
var dataAdapterGrid = new $.jqx.dataAdapter(sourceGrid,
{
contentType: ‘application/json; charset=utf-8’
}
$(“#jqxgrid”).jqxGrid({
source: dataAdapterGrid,
theme: theme,
width: gridWidth,
rowsheight: 30,
autoheight: true,
showstatusbar: true,
editable: true,
…
}
If I put a record: ‘content’ in the sourceGrid object, then a message appears “No data to display”, otherwise 15 empty rows.
Should I use a WebService ‘http://localhost:1216/Service.asmx/GetData’?
Please, help!
Thanks a lot!