dynamic columns in the header parts of DataTables
dynamic columns in the header parts of DataTables
hi, all
i have met a problem when i want to redefine the columns of the DataTables.
Here comes my requirement:
in my webpage, there are three buttons (A, B, C) and a DataTables. in the database, there are three tables (A,B,C). table_A has five columns. table_B has four columns, table_C has six columns.
when i click button A, the datatables get datas from table_A, and the columns number in DataTables will be five.
when i click button B, the datatables get datas from table_B, and the columns number in DataTables will be four.
when i click button C, the datatables get datas from table_C, and the columns number in DataTables will be six.
my problem is:
when i click button A, the datatables works well.
when i click button B, there are two headers (one header has five columns, another seems to have four columns).
when i click button C, the datatables doesn't work.
in addition, i used json data to initialize DataTables when i click every button like below:
[quote]
$.getJSON( "xxxxx", null, function (json) {
$("#list").dataTable( {
"bProcessing": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"aaData": json.aaData,
"aoColumns": json.aoColumns
} );
} );
[/quote]
i have met a problem when i want to redefine the columns of the DataTables.
Here comes my requirement:
in my webpage, there are three buttons (A, B, C) and a DataTables. in the database, there are three tables (A,B,C). table_A has five columns. table_B has four columns, table_C has six columns.
when i click button A, the datatables get datas from table_A, and the columns number in DataTables will be five.
when i click button B, the datatables get datas from table_B, and the columns number in DataTables will be four.
when i click button C, the datatables get datas from table_C, and the columns number in DataTables will be six.
my problem is:
when i click button A, the datatables works well.
when i click button B, there are two headers (one header has five columns, another seems to have four columns).
when i click button C, the datatables doesn't work.
in addition, i used json data to initialize DataTables when i click every button like below:
[quote]
$.getJSON( "xxxxx", null, function (json) {
$("#list").dataTable( {
"bProcessing": true,
"bPaginate": true,
"sPaginationType": "full_numbers",
"aaData": json.aaData,
"aoColumns": json.aoColumns
} );
} );
[/quote]
This discussion has been closed.