Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by VBorlongan on Jul 23, 2008 15:53
open dhtmlx forum
Dynamic Paging with JSON

Hello,

I'm trying to dynamicall load the page content via JSON. Although I'm able to pickup and format the resulting rows for the particular page, it is appending to the previous resultlist. What can I tweak on this code snippet to enable me to show just the requested page content?

By the way, i'm using the additiona the enterprise edition with the addition of dhtmlxgrid_json.js.

        tableGrid.attachEvent(\"onBeforePageChanged\", function(current, page) {
         new Ajax.Request("someURL?pagerequested=" + page, {
         onSuccess: function(transport) {
         var jsonData = transport.responseText;
         eval(\"var responseBean = (\" + jsonData + \")\");
         if(responseBean.bindings) {
         responseBean = responseBean.bindings;
         }
         tableGrid.parse(buildJSONData(responseBean.page), 'json');                
         return true;
         },
         onFailure: function() {
         alert(\"Error sending action to server.\", \"alert\");");
         }
        });

I'm also using JSON string with pos and total_count parameters.

Thank you in advance
Answer posted by Support on Jul 24, 2008 02:41
Technically you can organize dynamic paging with json based server side without any custom coding.
Grid already supports dynamical paging and it will work work for json based datasources as well.

        mygrid.enablePaging(true,30,null,"pagingArea",true,"recinfoArea");
        mygrid.load("dynscroll.php","json");

Full sample sent by email.