ajax - retrieve multiple data for jquery datatable -


i hava datatable returns 25 records @ clientside (out of 100 records). along 25 rows, want 1 array or data structure contains first column of 100 records

my code:

var otable = $('#tblclipart').datatable({         'bstatesave': true,                 'bprocessing': true,         'bserverside': true,         'aasorting': [[6, 'desc']],         'bfilter': false,         'idisplaylength': 25,         'spaginationtype': "bootstrap",         'sdom': 'rlfrtlip',         'aocolumns': [             // code             ],     'sajaxsource': '/handlers/manage.ashx' // handler page providing data }); 

handler code

list<clipartentity> clipartentitylist = null; clipartentitylist = //get data server - 100 records  var result = new {     itotalrecords = totalrecords,     itotaldisplayrecords = totalrecords, //display first 25          /* clipartids = clipartentitylist.select(m => m.clipartid ), can add line retrieve 1 column in array list */     aadata = clipartentitylist         .select(p => new[] {              convert.tostring("c"+p.clipartid),              p.clipartname + convert.tostring(p.sequence),              convert.tostring(p.categoryname),                        convert.tostring(p.clipartid),             p.clipartnameforsort         })         .skip(idisplaystart)         .take(idisplaylength) };  var serializer = new system.web.script.serialization.javascriptserializer(); var json = serializer.serialize(result); context.response.contenttype = "application/json"; context.response.write(json); 

i can add clipartids = clipartentitylist.select(m => m.clipartid ), var result variable 100 records first column data in array format

but problem how retrieve in client side ?

p.s. dont want make ajax call retrieve 1 column data because previous ajax call contains data.

you need use fnserverdata callback.. you've created custom clipartids return parameter, use client-side, add callback datatables initialisation:

var otable = $('#tblclipart').datatable({     'fnserverdata': function ( ssource, aodata, fncallback ) {             $.getjson(ssource, aodata, function (json) {                 // column of ids                 var clipartids = json.clipartids;                 fncallback(json);             });         },     'bstatesave': true,     ... 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -