json - Jquery DataTables : Not able to make dynamic header -
have 2 json files
json1
callback({ "docs":[ { "a":"qwe", "b":"asd", "c":"zxc", "d":"mnb", }] })
json2
callback({ "docs":[ { "1":"123", "2":"456", "3":"789", "4":"012", }] })
reading json file , displaying in table using jquery datatables plugin.
i want "a","b","c","d" , "1", "2", "3", "4" used table headers or column names
each json file called based on different check box click, there different column headers each json want columns/table headers dynamic.
here datatable initialization
var table = $('#example').datatable({ "data": items, "aocolumns": columns, "scrollx": true, "bautowidth": true, });
items variable contains parsed json data passed data , able data rendered in table
columns variable contains parsed json column names , passing "aocolumns" not getting dynamic header values
have defined default table header, request getting default header instead of respective dynamic header.
please let me know if missing anything
thanks in advance...!!!
it might easier re-initialize table beginning if want change data , columns definition.
use $('#example').datatable().fndestroy();
, call initialization code different items
, columns
variables.
here way this, documented on datatables plugin website (in case use .destroy()
instead of .fndestroy()
they're same thing, in different code setups):
Comments
Post a Comment