jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqxGrid – Empty Rows if JSON = {"data": null}
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 9 years, 6 months ago.
-
Author
-
Hi JQX-Team,
i need help from you.
In all my Grids i’ve one empty Row if the response of my PHP-JSON like {“data”:null}.I’ve create an example here.
Thanks and LLAP
ChristianHi Christian,
Thanks for feedback. Check if the data is null, and do not bind it if it is or call “clear”
$(document).ready(function () { var data = '{"data":null}'; var source = { datatype: "json", datafields: [ { name: 'CompanyName', type: 'string' }, { name: 'ContactName', type: 'string' }, { name: 'ContactTitle', type: 'string' }, { name: 'Address', type: 'string' }, { name: 'City', type: 'string' }, { name: 'Country', type: 'string' } ], localdata: data, root: 'data' }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 850, source: dataAdapter, ready: function() { $("#jqxgrid").jqxGrid('clear'); }, columnsresize: true, columns: [ { text: 'Company Name', datafield: 'CompanyName', width: 250 }, { text: 'Contact Name', datafield: 'ContactName', width: 150 }, { text: 'Contact Title', datafield: 'ContactTitle', width: 180 }, { text: 'City', datafield: 'City', width: 120 }, { text: 'Country', datafield: 'Country'} ] }); });
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHello JQX-Team,
Now the Widget Response “jqxDataAdapter: JSON Parse error! Invalid JSON. Please, check your JSON or your jqxDataAdapter initialization!” in all Browsers.
Your Code is:console.log('jqxDataAdapter: JSON Parse error! Invalid JSON. Please, check your JSON or your jqxDataAdapter initialization!');
.
Can you please suppress this console.log for IE in future Versions?Best Regards
Christian B.Hi Christian,
IE supports console.log. Only very old versions of that browser does not support it, but you can use polyfills in your specific case. This is an Error when the data is wrong so whether it writes the Error in the console or pops an Alert is the same.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.