jQWidgets Forums
jQuery UI Widgets › Forums › Grid › TypeError: Cannot read property 'visiblerecords' of null
Tagged: grid control
This topic contains 9 replies, has 3 voices, and was last updated by Nicolai 11 years, 10 months ago.
-
Author
-
TypeError: Cannot read property ‘visiblerecords’ of null [http://localhost:53094/jqwidgets/jqxgrid.js:7]
I get this error, with my grid.
Everything seems to be working as it should, but I hate having javascript errors.
Any ideas why I get this? Any ideas to how I get rid of it?In case you wish to report something, then please, post a sample which demonstrates it.
Alright, this is my gridview.
I have played around with it a bit, and if I remove width: ‘100%’, the error goes away.
function InitGridView() { $("#jqxgrid").jqxGrid({ autoheight: true, theme: 'lpstore', columnsresize: true, pagesizeoptions: ['10', '25', '50', '100'], pagesize: 25, width: '100%', altrows: true, sortable: true, pageable: true, localization: getLocalization(), autorowheight: true, columns: [ { text: '', datafield: 'typeid', cellsrenderer: imgConverter, width: 32 }, { text: 'perlp', datafield: 'IskPerLp', cellsalign: 'right', cellsformat: 'd2' }, { text: 'Item', datafield: 'typename', cellsrenderer: multiLineRenderer, width: 300 }, { text: 'Investment', datafield: 'TotalCost', cellsalign: 'right', cellsformat: 'd2' }, { text: 'Return', datafield: 'TotalReturn', cellsalign: 'right', cellsformat: 'd2' }, { text: 'Profit', datafield: 'TotalProfit', cellsalign: 'right', cellsformat: 'd2' }, { text: 'Sell orders', datafield: 'volume', cellsalign: 'right', width: 100 } ]}); }
Hi,
Unfortunately, still unable to reproduce that.
Here’s my code:
<!DOCTYPE html><html lang="en"><head> <title id='Description'>This example illustrates the Grid filtering feature. Enter some data into the Filter Row.</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.1.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script> <script type="text/javascript" src="generatedata.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = ''; var data = generatedata(250); var source = { localdata: data, datafields: [ { name: 'name', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'available', type: 'bool' }, { name: 'date', type: 'date' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' } ], datatype: "array" }; var dataAdapter = new $.jqx.dataAdapter(source); var getLocalization = function () { var localizationobj = {}; localizationobj.pagergotopagestring = "Gehe zu:"; localizationobj.pagershowrowsstring = "Zeige Zeile:"; localizationobj.pagerrangestring = " von "; localizationobj.pagernextbuttonstring = "voriger"; localizationobj.pagerpreviousbuttonstring = "nächster"; localizationobj.sortascendingstring = "Sortiere aufsteigend"; localizationobj.sortdescendingstring = "Sortiere absteigend"; localizationobj.sortremovestring = "Entferne Sortierung"; localizationobj.firstDay = 1; localizationobj.percentsymbol = "%"; localizationobj.currencysymbol = "€"; localizationobj.currencysymbolposition = "after"; localizationobj.decimalseparator = "."; localizationobj.thousandsseparator = ","; var days = { // full day names names: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], // abbreviated day names namesAbbr: ["Sonn", "Mon", "Dien", "Mitt", "Donn", "Fre", "Sams"], // shortest day names namesShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] }; localizationobj.days = days; var months = { // full month names (13 months for lunar calendards -- 13th month should be "" if not lunar) names: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""], // abbreviated month names namesAbbr: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez", ""] }; var patterns = { d: "dd.MM.yyyy", D: "dddd, d. MMMM yyyy", t: "HH:mm", T: "HH:mm:ss", f: "dddd, d. MMMM yyyy HH:mm", F: "dddd, d. MMMM yyyy HH:mm:ss", M: "dd MMMM", Y: "MMMM yyyy" } localizationobj.patterns = patterns; localizationobj.months = months; localizationobj.todaystring = "Heute"; localizationobj.clearstring = "Löschen"; return localizationobj; } $("#jqxgrid").jqxGrid( { width: '100%', source: dataAdapter, pagesizeoptions: ['10', '25', '50', '100'], pagesize: 25, pageable: true, columnsresize: true, autoheight: true, autorowheight: true, editable: true, theme: theme, localization: getLocalization(), selectionmode: 'singlecell', columns: [ { text: 'Name', columntype: 'textbox', filtertype: 'textbox', datafield: 'name', width: 115 }, { text: 'Produkt', filtertype: 'textbox', datafield: 'productname'}, { text: 'Datum', datafield: 'date', columntype: 'datetimeinput', filtertype: 'date', width: 210, cellsalign: 'right', cellsformat: 'd' }, { text: 'Qt.', datafield: 'quantity', columntype: 'numberinput', filtertype: 'textbox', cellsalign: 'right' }, { text: 'Preis', datafield: 'price', columntype: 'numberinput', filtertype: 'textbox', cellsformat: "c2", cellsalign: 'right' } ] }); }); </script></head><body class='default'> <div id="jqxgrid"> </div></body></html>
What steps should we follow to reproduce it?
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI don’t really know how to reproduce. To be honest, I don’t know when this error started occuring. I’m pretty sure it wasn’t always there.
Anyhow, I have uploaded my site, so maybe that’s the best way to see it?
http://www.lpbeta.noonecares.dk/LpStore/Corporation/Court%20Chamberlain
This is the direct link to the page where I use the gridview.
Sorry for being a little vague, I just don’t really know how to explain it.Maybe I should have mentioned, that all the grid code is in “/Scripts/Corporation.js” 🙂
Hi,
I am not sure what could be wrong in that page. I also could not find which version you use as the header information about the version seems to be removed. In case you do not use the latest version – 2.9.2, I suggest you to upgrade to it.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comAha, I think I have solved it.
It seems to be due to me creating the grid, and setting the width, BEFORE adding any data to it.I have changed my init code, to take in the dataadapter, and set it right away, and now it works!
Peter, yea the ASP.NET MVC framework I’m developing in, has this neat bundle function, where it bundles up all the js files.
I guess it removes all the comments, and minimizes it even more.It is 2.9.2 I am using 🙂
I have to say, you guys have an amazing product and amazing support.
Thanks to all of you. And sorry for being vague.
-
AuthorPosts
You must be logged in to reply to this topic.