Title: [SOLVED] Can't figure out why not loading
Post by: MB34 on June 24, 2015, 01:56:49 PM
I am having issues loading a jQuery EasyUI Datagrid at this URL: http://www.scic.com/files/event_attendance (http://www.scic.com/files/event_attendance) Enter the event code 20150731TXAO and click the Load Attendees button. This is the raised Exception and Call Stack: Uncaught TypeError: Cannot read property 'length' of undefined
_745.renderTable @ jquery.easyui.min.js:10102 _745.render @ jquery.easyui.min.js:10079 _612 @ jquery.easyui.min.js:9032 (anonymous function) @ jquery.easyui.min.js:9682 st.extend.each @ jquery.js:642 st.fn.st.each @ jquery.js:263 $.fn.datagrid @ jquery.easyui.min.js:9657 (anonymous function) @ (index):169 st.Callbacks.f @ jquery.js:1026 st.Callbacks.p.fireWith @ jquery.js:1138 r @ jquery.js:8021 st.ajaxTransport.send.r @ jquery.js:8558 XMLHttpRequest.send (async) st.ajaxTransport.send @ jquery.js:8475 st.extend.ajax @ jquery.js:7930 st.each.st.(anonymous function) @ jquery.js:7569 loadAttendees @ (index):163 (anonymous function) @ (index):143 st.event.dispatch @ jquery.js:3045 st.event.add.y.handle @ jquery.js:2721
The data is loaded in the loadAttendees function in a jQuery $.get. It is stored in the variable window.data and then the datagrid is initialized. function loadAttendees(EventCode) { $.get('getEventAttendees.php?event_code='+EventCode, function(data) { window.data = data; $("#upload").hide(); $("#grid_area").show(); $('#dg').datagrid({ title:'Event Attendees', width:'100%', height:600, remoteSort:false, nowrap:false, fitColumns:true, striped: true, border:true, collapsible:true, data: window.data, toolbar:"#tb", columns:[[ {field:'event_code', visible:false}, {field:'participantid',title:'Alliance#', width:60, sortable:true}, {field:'full_name', title:'Full Name', width:100, editor:'text', sortable:true}, {field:'lic_num', title:'License Number', width:60, editor:'text'}, {field:'lic_state', title:'License State', width:40, editor:'text'}, {field:'want_ce', title:'CE', width:10, editor:'checkbox'}, {field:'attended', title:'AT', width:10, editor:'checkbox'} ]] }); }); };
I can't understand why it doesn't load any data. This is the data it is trying to load: "{"total":2,"rows":[{"event_code":"20150731TXAO","participantid":1158341,"full_name":"Eddie Shipman","lic_num":110987,"lic_state":"TX"},{"event_code":"20150731TXAO","participantid":1079745,"full_name":"Dustin Payne","lic_num":231896,"lic_state":"TX"}]}"
Title: Re: Can't figure out why not loading
Post by: stworthy on June 24, 2015, 06:08:56 PM
You load a wrong data type, please use the code below instead: $('#dg').datagrid({ data: JOSN.parse(window.data) });
Title: Re: Can't figure out why not loading
Post by: MB34 on July 03, 2015, 02:37:20 PM
Thanks. That did it...
|