jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Grid does not shown data from JSON
Tagged: angular grid, data, grid, jquery grid, jqxgrid, json, php
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 9 years, 10 months ago.
-
Author
-
Hi all,
I have a grid which gets the data by a WS, which works, however whatever I move, I cant get the data being displayed in the grid.
Pretty sure doing something wrong but cant figure out what.Again I get the data in but it does not display, here my code:
This string is being retrieved from server by data.d, wehere d is the initial parameter:
var data = {“content”:[{“id”:1,”sys_product_id”:1,”catagory_type_id”:0,”product_type_id”:0,”owner_id”:0,”sys_price_id”:1,”currency_type_id”:442,”discount_type_id”:0,”name”:”Test product”,”description”:”Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test \\n Test Test Test Test Test Test Test “,”active”:true,”price”:2.30000,”discount”:0.0,”launch_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”depreciation_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”sync_datetime”:{“second”:null,”minute”:”37″,”hour”:”09″,”day”:”18″,”month”:”05″,”year”:2015,”week”:21,”dayname”:”Monday”,”monthname”:”May”,”isToday”:false},”from_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”till_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false}},{“id”:2,”sys_product_id”:2,”catagory_type_id”:0,”product_type_id”:0,”owner_id”:0,”sys_price_id”:3,”currency_type_id”:442,”discount_type_id”:0,”name”:”Product two”,”description”:”With different text”,”active”:true,”price”:3.00000,”discount”:0.0,”launch_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”depreciation_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”sync_datetime”:{“second”:null,”minute”:”44″,”hour”:”09″,”day”:”20″,”month”:”05″,”year”:2015,”week”:21,”dayname”:”Wednesday”,”monthname”:”May”,”isToday”:false},”from_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”till_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false}},{“id”:3,”sys_product_id”:3,”catagory_type_id”:0,”product_type_id”:0,”owner_id”:0,”sys_price_id”:4,”currency_type_id”:442,”discount_type_id”:0,”name”:”2 bread for price of 1″,”description”:””,”active”:true,”price”:5.60000,”discount”:0.0,”launch_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”depreciation_date”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”sync_datetime”:{“second”:null,”minute”:”32″,”hour”:”10″,”day”:”20″,”month”:”05″,”year”:2015,”week”:21,”dayname”:”Wednesday”,”monthname”:”May”,”isToday”:false},”from_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false},”till_datetime”:{“second”:null,”minute”:”00″,”hour”:”00″,”day”:”01″,”month”:”01″,”year”:1970,”week”:1,”dayname”:”Thursday”,”monthname”:”January”,”isToday”:false}}]}var source =
{
dataType: ‘json’,
contentType: ‘application/json; charset=UTF-8’,
type: “POST”,
datafields: datafields,
//async: false,
id: ‘id’,
//localdata:
root: ‘content’,
url: “wsservices/general.asmx/SystemHandler”,
formatdata: function (data) {
$.extend(data, {
ip: ip,
station: station,
q: session});
return JSON.stringify(data);
} ,
pagenum: 1,
pagesize: 20,
pager: function (pagenum, pagesize, oldpagenum) {
console.log(“pagenum: ” + pagenum + “, pagesize: ” + pagesize + “, oldpagenum: ” + oldpagenum);
// callback called when a page or page size is changed.
},
updaterow: function (rowid, rowdata, commit) {
// synchronize with the server – send update command
// call commit with parameter true if the synchronization with the server is successful
// and with parameter false if the synchronization failder.
commit(true);
}
};
var dataAdapter = new $.jqx.dataAdapter(source, {
autoBind: true,
downloadComplete: function (data, status, xhr) {
var thisData = $.parseJSON(data.d);
var records = new Array();
for (var i = 0; i < thisData.content.length; i++) {
var employee = thisData.content[i];
employee.name = employee.name;
employee.description = employee.description;
records.push(employee);
}
return records;
},
loadComplete: function (data) { },
loadError: function (xhr, status, error) { }
});
$gridOne.jqxGrid({
source: dataAdapter,
width: ‘100%’,
selectionmode: ‘multiplerowsextended’,
sortable: true,
pageable: true,
autoheight: true,
columnsresize: true,
showtoolbar: true,
//showfilterrow: true,
//filterable: true,
rowdetails: true,
rowdetailstemplate: { rowdetails: “<div style=’margin: 10px;’><ul style=’margin-left: 30px;’><li class=’title’> - Notes
<div class=’information’></div><div class=’notes’></div></div>”, rowdetailsheight: 200 },
ready: function () {
$(“#tree1Grid”).jqxGrid(‘showrowdetails’, 0);
$(“#tree1Grid”).jqxGrid(‘showrowdetails’, 1);
},
initrowdetails: initrowdetails,
rendertoolbar: function (toolbar) {
var me = this;
toolbar.append($searchDiv);
},
columns: columns
});