javascript - Assign ID to datatable row from json data -
i'm new datatable jquery plugin. got stuck more 2 days. have json data, still cant load table , want assign first column id of row
here html:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="accdetailtable"> <thead> <tr> <th>currency</th> <th>current/savings account no.</th> <th>securities account no.</th> </tr> </thead> <tbody> </tbody> </table>
and initialization
var otable=$('#accdetailtable').datatable( { "bprocessing": true, "bserverside": true, "sajaxsource": contextpath + "/user/investorajax?method=getinvestoraccdetaillist", "ideferloading": 57, } );
return jsondata server :
{"secho":1,"icolumns":4,"itotalrecords":16,"itotaldisplayrecords":16, "aadata": [{"dt_rowid":2032,"currency":1,"currentaccno":"aa","secureaccno":"aa"}, {"dt_rowid":2033,"currency":1,"currentaccno":"111","secureaccno":"111"}, {"dt_rowid":2034,"currency":1,"currentaccno":"a","secureaccno":"aa"}, ]} }
but hit :
datatables warning (table id = 'accdetailtable'): added data (size undefined) not match known number of columns (3)
your datatables waiting 3 entries per line , give four. in table declaration (in html part) specify new header cell <th>
@ beginning of row. put ids in it. after datatables initialization can hide first column using fnsetcolumnvis(index, visibility)
function :
otable.fnsetcolumnvis(0, false); //it hide first column
doing each row containing id (dt_rowid) not displaying it.
Comments
Post a Comment