Categories | Question details Back To List | ||
Loading large amount of data using JSON, paging and dynamic loading possible? Hello there. I'm curious about if I could use the dhtmlXgrid to load my data from JSON?! I'm currently using webservices to retrieve the data for the clientside-controls and I'm wondering if the grid would still be able to have paging and dynamic loading like when enableSmartRendering is active. I cannot use loadXML because I need to work against a webservice calling something like this MyWebService.GetData(int offset, int count, callback) But since I do have quite a massive amount of data which needs to handled, I'm in need of paging and data on demand loading. Please help me. Thanks in Advance. Answer posted by Support on Jun 02, 2008 06:50 You can use the paging and smart rendering with JSON as well. But you can't use both mentioned modes with dynamic loading ( dynamic paging, dynamic smart rendering ) If mentioned functionality is critical in your case - we can provide some kind of patch , which will add ability to work with dynamic JSON based modes ( it will be added as part of next version in any case, just was not well tested to include in latest release ) Answer posted by David on Jun 02, 2008 08:44 Thanks for your fast reply. Using your grid with either dynamic paging or smart rendering will do just fine for us. Actually I'm implementing your grid (standard gpl 1.6 for starters) in our application to test the functionality. I'm quite amazed about this grid, since the idea of a client-side only grid with so much features is enormous. But I encountered also difficulties, regarding JSON again. Our Webservice is returning a serialized datatable containing all the columns the grid shall contain. With the returned JSON I do the following: (result[i].Value contains the JSON) mygrid = new dhtmlXGridObject(result[i].TargetControlID);mygrid.setImagePath("../../codebase/imgs/"); mygrid.setHeader("Sales, Book Title, Author"); mygrid.setInitWidths("70,250,*"); mygrid.setColAlign("right,left,left"); mygrid.setColTypes("dyn,ed,ed"); mygrid.setColSorting("int,str,str"); mygrid.setSkin("modern"); mygrid.parse(result[i].Value,"json"); The following js-error says "rows.length" is null or not an object. I am quite sure, that the error results because my datatable is serialized different to yours in the data.json file, because trying to "load" this file works just fine. Any clues what I am missing when serializing? Thanks, David Answer posted by Support on Jun 03, 2008 01:32 The parse command expect to receive the js objects, something similar to next. var data={ rows:[ { id:1001, data:[ "100", "A Time to Kill", "John Grisham", "12.99", "1", "05/01/1998"] }, { id:1002, data:[ "1000", "Blood and Smoke", "Stephen King", "0", "1", "01/01/2000"] } ]} grid.parse(data); The error which occurs in your case, may be caused a) by using different json format b) by using string with json encoding instead of object In second case - just convert string back to object as eval("data="+result[i].Value+";"); mygrid.parse(data,"json"); Answer posted by David on Jun 09, 2008 02:02 All problems solved thanks to your suggestion. Thanks and best regards, David |