php - aoColumns of datatables are not working properly -


i trying handle value of aocolumns other php page. not coming properly, whereas if use static value working. code : in php page

$aocolumn = array("null","null","null","{bsortable: false}"); <input type="hidden" name="aocolumn" id="aocolumn" value="' . implode(",",$aocolumn) . '"> 

in js page

var aos = $('#aocolumn').val();  var ao = (aos)?aos.split(","):[];  $.each(ao,function(i){  }); 

and in datatable declaration: "aocolumns":ao

but not working. please let me know issue. in advance.

update

i got know that, in case aocolumns prints ["null", "null", "null", "{bsortable: false}"] whereas should [null,null,null,object{bsortable=false}]. how it?

this fun 1 :-) taken setup 1:1 (just 3 columns though) :

<? $aocolumn = array("null", "{bsortable: false}", "null"); echo '<input type="hidden" name="aocolumn" id="aocolumn" value="' . implode(",",$aocolumn) . '">'; ?> 

js

var ao = []; var aos = $('#aocolumn').val().split(','); (var i=0;i<aos.length;i++) {     if (aos[i]=='null') {         //no need processing         ao.push('{ null }');     } else {         //remove {, } , whitespace, return array splitted :         var s = aos[i].replace('{','').replace('}','').replace(' ','').split(':');         //create object         var o = {};         //here need force real boolean instead of "false"         o[s[0].tostring()]=(s[1]=="false") ? false : true;         ao.push(o);     } }  $('#table').datatable({     "aocolumns": ao }); 

viola. datatables parses ao correct, second column not sortable.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -