Jquery Datatable null column -
hi have created jquery datatable using below code..
the column email id , activated date may nullable. when render table showing 'request unknown parameter 'email' data source row 0'
var tblallkeys = $('#tblallkeys').datatable({ "bdestroy" : true, "bprocessing" : true, "bserverside" : true, "blenthchange" : false, "idisplaylength" : 10, "sajaxsource" : "loadallkeys", "olanguage" : { "ssearch" : "search activation key:" }, "aocolumns" : [ {"stitle" : "no.","mdata" : null,"atargets": [ 0 ], "fnrender" : function(obj) { var columnindex = obj.osettings._idisplaystart + obj.idatarow+1 return columnindex; } }, {"stitle" : "activation key","mdata" : "key", "bsearchable" : true}, {"stitle" : "email id","mdata" : "email" , "bsearchable" : false}, {"stitle" : "app edition","mdata" : "edition", "bsearchable" : false}, {"stitle" : "batch code","mdata" : "batch", "bsearchable" : false}, {"stitle" : "activated date","mdata" : "adate" , "bsearchable" : false}, {"stitle" : "generated date","mdata" : "gdate", "bsearchable" : false}, {"stitle" : "status","mdata" : "status", "bsearchable" : false}, ], "fnserverdata" : function(ssource, aodata, fncallback) { $.ajax({ "datatype" : 'json', "type" : "get", "url" : ssource, "data" : aodata, "success" : fncallback }); }, "spaginationtype" : "full_numbers", });
you can make use of columns.defaultcontent
option available per docs on error, display default value or empty string when column's doesn't have value.
"aocolumns": [{ "stitle": "no.", "mdata": null, "atargets": [0], "fnrender": function(obj) { var columnindex = obj.osettings._idisplaystart + obj.idatarow + 1 return columnindex; } }, { "stitle": "activation key", "mdata": "key", "bsearchable": true }, { "stitle": "email id", "defaultcontent":"",//or specify other value "mdata": "email", "bsearchable": false }, { "stitle": "app edition", "mdata": "edition", "bsearchable": false }, { "stitle": "batch code", "mdata": "batch", "bsearchable": false }, { "stitle": "activated date", "mdata": "adate", "bsearchable": false }, { "stitle": "generated date", "mdata": "gdate", "bsearchable": false }, { "stitle": "status", "mdata": "status", "bsearchable": false }, ],
its assign defaultcontent
option columns if sure of column
might come empty.
Comments
Post a Comment