在我的表单中,我有一个2选择的选择框: 当你选择其中一个时,我的DataTable必须改变他的专栏:
//Changing TYpe of Price level will change datatable
$('#price_method').on("change", function(){
//Declare the variable
var oTable=$('#item_pricelvl').DataTable();
oTable.clear();
//Destroying the table and then rebuilding it again
oTable.destroy();
//If Selected Price Override
if ($(this).val()=="PO"){
//I gotta hide a column
$('#item_pricelvl').DataTable({
"columnDefs":[
{
"class":"details-control",
},
{
"targets":['_all'],
"orderable":false
},
//I'm hiding the 4th column
{ "visible": false, "targets": 4 },
"Column"
],
})
}else{ //Else I can show all columns
$('#item_pricelvl').DataTable({
"columnDefs":[
{
"class":"details-control",
},
{
"targets":['_all'],
"orderable":false
},
"Column"
],
})
}
});
//INSERT NEW PRICE LEVEL INTO THE ITEM PRICE TABLE
$('#insertplvl').click(function(){
//Checking what method is selected
if ($('#price_method').val()=="CM"){
//starting to add the new row into the DataTable, and No columns hiding
it_det.row.add([
"D",
"COST MARKUP",
"1",
"999999999",
"0.00",
"0.00",
"<input type='checkbox' name='chkdet' class='chk_plvl' id='"+ct_row+"'/>"
]).draw(false);
}else{
//starting to add the new row into the DataTable, and adding just 6 values because of the hide column
it_det.row.add([
"D",
"PRICE OVERRIDE",
"1",
"999999999",
"0.00",
"<input type='checkbox' name='chkdet' class='chk_plvl' id='"+ct_row+"'/>"
]).draw(false);
}
//Increasing the counter
ct_row++;
})
&#13;
<table id="item_pricelvl" class="table table-bordered table-striped">
<thead>
<tr>
<th>Price Level</th>
<th>Pricing Method</th>
<th>From Quantity</th>
<th>To Quantity</th>
<th>Markup Amount</th>
<th>Unit Price</th>
<th><input type="checkbox" class="checkall" /></th>
</tr>
</thead>
</table>
&#13;
当我尝试插入选择&#34; POP时,我收到此错误:
DataTables警告:table id = item_pricelvl - 请求的未知参数&#39; 6&#39;对于第0行,第6列。有关此错误的详细信息,请参阅http://datatables.net/tn/4