php - YUI-2 Datatable : Dynamic column definition with Server side AJAX pagination sorting -
i using below code create yui datatable dynamic data(columns). facing issue in server side pagination. of working fine client side pagination, need server side pagination, page loading time reduced. can me on fix issue. since i'm struggling in area past 2 days.server side pagination ajax render data expectation.
here code used
dataprovider.prototype = { url:null, data:null, ds:null, getdata:function() {return this.data}, initialize:function(){ var str = generaterequest(); var newurl = this.url+str; yahoo.util.connect.asyncrequest('get', newurl, this); }, success:function(response){ var responseval = yahoo.lang.json.parse(response.responsetext); var columnlist = responseval.columnlist; var sortedby = responseval.sortedby; this.data = responseval.results; if(this.data == '') { $('#dynamicdata').html('<font style="color:red;"> no data found!</font>'); } else { this.ds = new yahoo.util.functiondatasource(function(){return this.dataprovider.getdata()}); this.ds.responseschema = { resultslist:"results", fields:columnlist, // access values in server response metafields: { totalrecords: "totalrecords", startindex: "startindex" } } this.ds.dataprovider = this; // datatable configuration var myconfigs = { paginator: new yahoo.widget.paginator({ rowsperpage:20 }), // enables pagination width:"80%", height:"auto" }; // formatting cell colour based on values var mycustomformatter = function(elliner, orecord, ocolumn, odata) { var columnkey = ocolumn.getkey(); var frmcurrentperoid = $('#from').val(); //var frmcurrentperoid = '2013-03-13'; var defaultlabels = ['product type','total 1','total 2','change']; if (isdate(columnkey) && $.inarray(columnkey, defaultlabels) === -1) { if(columnkey < frmcurrentperoid) { yahoo.util.dom.addclass(elliner.parentnode,'orange'); elliner.innerhtml = odata; //alert('blue'); } else { yahoo.util.dom.addclass(elliner.parentnode,'blue'); elliner.innerhtml = odata; } } else { if(columnkey == 'total 1') { yahoo.util.dom.addclass(elliner.parentnode,'orange'); elliner.innerhtml = odata; //alert('blue'); } else if(columnkey == 'total 2') { yahoo.util.dom.addclass(elliner.parentnode,'blue'); elliner.innerhtml = odata; //alert('blue'); } else if(columnkey == 'change') { split_data = odata.tostring().split('_'); var fielddata = null; var fieldformatter = null; fielddata = split_data[0]; fieldformatter = split_data[1]; if(fieldformatter == 'green') { yahoo.util.dom.addclass(elliner.parentnode,'green'); elliner.innerhtml = fielddata; } if(fieldformatter == 'red') { yahoo.util.dom.addclass(elliner.parentnode,'red'); elliner.innerhtml = fielddata; } } else if(columnkey == 'product name') { var filterstr = odata.substring(0,30); elliner.innerhtml = '<a href="..product-detail.php?product_id='+orecord._odata.product_id+'&height=400&width=850&modal=true" title="'+odata+'" class="thickbox" target="_self">'+filterstr+'</a>'; //alert('blue'); } else { elliner.innerhtml = odata; } } }; // add custom formatter shortcuts yahoo.widget.datatable.formatter.mycustom = mycustomformatter; //yahoo.widget.datatable.formatlink = formatlink; /* make call initialize table using data set */ var mydatatable = new yahoo.widget.datatable("dynamicdata", columnlist, this.ds, myconfigs); } }
}
followed code posted in page click here
thanks in advance, raja
i haven't been doing yui2 quite time no longer able directly. perhaps example can help: http://www.satyam.com.ar/yui/#serverdriven . remember there big changes in 2.6 , examples marked 2.4, perhaps no longer work.
Comments
Post a Comment