jQuery UI Widgets › Forums › Grid › jqxgrid return empty source
Tagged: angular grid, display, empty, emptydatastring, grid, hide, jquery grid, jqxgrid, source
This topic contains 7 replies, has 2 voices, and was last updated by Dimitar 9 years ago.
-
Author
-
this is my code. is there a way for me to block grid from display if the return source is empty(no data return from ctrl_no_status.php).
var getCtrlNoStatus = function(ctrl_no) { var url = "lib/ctrl_no_status.php?ctrl_no="+ctrl_no; // prepare the data var source = { datatype: "json", datafields: [ { name: 'ControlNo' }, { name: 'Title' }, { name: 'Item' }, { name: 'Action' } ], id: 'id', url: url, root: 'data' }; var dataAdapter = new $.jqx.dataAdapter(source); $("#status").jqxGrid( { width: 870, autoheight: true, source: dataAdapter, theme: theme, sortable: true, rowsheight: 40, //filterable: true, keyboardnavigation: false, columns: [ { text: 'Control No', datafield: 'ControlNo', width: 100 }, { text: 'Title', datafield: 'Title', width: 500 }, { text: 'Item', datafield: 'Item', width: 150 }, { text: 'Action', datafield: 'Action', width: 150 } ] }); enable(); }
Hello sathiyaseelan8,
You can try the following:
var getCtrlNoStatus = function(ctrl_no) { var url = "lib/ctrl_no_status.php?ctrl_no=" + ctrl_no; // prepare the data var source = { datatype: "json", datafields: [{ name: 'ControlNo' }, { name: 'Title' }, { name: 'Item' }, { name: 'Action' }], id: 'id', url: url, root: 'data' }; var dataAdapter = new $.jqx.dataAdapter(source, { beforeLoadComplete: function(records) { if (records.length === 0) { $("#status").css('visibility', 'hidden'); } } }); $("#status").jqxGrid({ width: 870, autoheight: true, source: dataAdapter, theme: theme, sortable: true, rowsheight: 40, //filterable: true, keyboardnavigation: false, columns: [{ text: 'Control No', datafield: 'ControlNo', width: 100 }, { text: 'Title', datafield: 'Title', width: 500 }, { text: 'Item', datafield: 'Item', width: 150 }, { text: 'Action', datafield: 'Action', width: 150 }] }); enable(); }
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/thank for your response.
its not working. it still displaying the grid with no data to display message.
from where you get the ‘records’. do i need to declare it somewhere?
Hi sathiyaseelan8,
records is an argument of the beforeLoadComplete callback function. Please take a closer look at the proposed dataAdapter definition:
var dataAdapter = new $.jqx.dataAdapter(source, { beforeLoadComplete: function(records) { if (records.length === 0) { $("#status").css('visibility', 'hidden'); } } });
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/is there a way where i can call a function when the returned data is NULL?
Hi sathiyaseelan8,
Alternatively, you can try the following:
$("#status").jqxGrid({ width: 870, autoheight: true, source: dataAdapter, theme: theme, sortable: true, rowsheight: 40, //filterable: true, keyboardnavigation: false, ready: function() { var rows = $("#status").jqxGrid('getrows'); if (rows.length === 0) { $("#status").css('visibility', 'hidden'); } }, columns: [{ text: 'Control No', datafield: 'ControlNo', width: 100 }, { text: 'Title', datafield: 'Title', width: 500 }, { text: 'Item', datafield: 'Item', width: 150 }, { text: 'Action', datafield: 'Action', width: 150 }] });
This approach should work when the data returned is null and there is no need to implement beforeLoadComplete.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/hi dimitar,
sometimes jqxgrid refused to load data if there are more than 5000 records. in this case, is there a way to customize “no data to display” to any other message?
Hi sathiyaseelan8,
Maybe you should make use of the virtualmode functionality, which allows the grid to load very large numbers of rows on-demand. Here are two examples with it: Virtual Paging and Virtual Scrolling.
As for the “No data to display” message, it can be changed/localized by modifying the value of the emptydatastring localization member.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.