jQWidgets Forums
jQuery UI Widgets › Forums › Grid › dataAdapter not defined
This topic contains 2 replies, has 2 voices, and was last updated by jkapasi 7 years, 8 months ago.
-
AuthordataAdapter not defined Posts
-
Hi,
I am getting following error :
Unable to get property ‘dataAdapter’ of undefined or null reference
The error appears in following code:
var dataadapter = new $.jqx.dataAdapter(source, { loadError: function (xhr, status, error) { alert(error + ":" + xhr.responseText); } });
I think the problem is because of the scripts and css file not being referred.
Following is a list of all the files being imported:<script type="text/javascript" src="../../js/jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxdata.export.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxcheckbox.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.edit.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.export.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.columnsreorder.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.filter.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.sort.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.pager.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.grouping.js"></script> <script type="text/javascript" src="../../js/jqwidgets/jqxgrid.storage.js"></script> <link rel="stylesheet" href="../../js/jqwidgets/styles/jqx.base.css" type="text/css" /> <link rel="stylesheet" href="../../js/jquery-ui.css">
I can see in the browser that all the files are being referred. Is there anything missing in this?
Thank You.
Regards
JashHi Jash,
This error means that when you try to use the dataAdapter, the script is not yet loaded. Initialize the widgets within document.ready callback as we do in our demos to ensure all scripts are loaded. Also check your URLs to scripts.
Hi,
I tried initializing the widget in a function which is called from document.ready callback. But still it is not working. Following is the code:
var columns, datafields; $(document).ready(function () { columns = [{ text: 'Product Name', datafield: 'ProductName', width: 250 }, { text: 'Quantity per Unit', datafield: 'QuantityPerUnit', width: 200 }]; datafields = [{ name: 'ProductName', type: 'string' }, { name: 'QuantityPerUnit', type: 'int' }]; LoadGridWithData(); }); function LoadGridWithData() { var source = { datatype: "json", datafields: datafields, url: "Data.jsp", root: 'Rows', beforeprocessing: function (data) { source.totalrecords = data[0].TotalRows; } }; var dataadapter = new $.jqx.dataAdapter(source, { loadError: function (xhr, status, error) { alert(error + ":" + xhr.responseText); } }); $("#gridBatchList").jqxGrid( { source: dataadapter, altrows: true, width: "100%", height: screen.height - 250, selectionmode: selectionmode, filterable: true, enablebrowserselection: true, sortable: true, autoheight: true, pageable: true, columnsresize: true, columnsreorder: true, autorowheight: false, ready: function () { }, columns: columns, }); $("#gridBatchList").on("bindingcomplete", function (event) { gridbindingcomplete(); }); $("#gridBatchList").on("pagechanged", function (event) { gridPageChanged(); }); $("#gridBatchList").on("rowselect", function (event) { gridRowSelect(); }); $("#gridBatchList").on('rowunselect', function (event) { gridRowUnselect(); }); }
The URL of the script tags are also verified and are correct.
Thank You.
Regards
Jash -
AuthorPosts
You must be logged in to reply to this topic.