unable to get column Index to remove the column from data Table1.9
unable to get column Index to remove the column from data Table1.9

hai to all,
here my requirement is removing a column from data table using drag and drop on treeview ;i am unable to get the column Index here;please guide me how to acheive this;If i need any api's guide me how to add it;here is my code:
@import "../DataTabels/demo_table.css";
debugger;
$(document).ready(function () {
$(".treeNode").draggable({ helper: 'clone' });
$("#droppable").droppable({
drop: function (event, ui) {
var columnName = $(ui.draggable).text();
var mytable = $("#sampleTable").dataTable(),
iter = 0;
//adding dragged treeview Node as column in data table
mytable.find('tr').each(function () {
var trow = $(this);
if (trow.index() === 0) {
trow.append('' + columnName + '');
}
else if (trow.index() >= 1) {
trow.append(' Acer ');
}
iter += 1;
});
var oTable = $("#sampleTable").dataTable();
oTable.fnDestroy();
//displaying Data
$("#sampleTable").dataTable();
}
});
});
$(document).ready(function () {
$("#sampleTable tr ").draggable({
cursor: 'move',
stack: $('#TreeviewDiv')
});
$("#TreeviewDiv").droppable({
drop: function (event, ui) {
var oTable = $("#sampleTable").dataTable();
//when i dropped on treeview Data Table column has to be delete.
//getting position of column
var aPos = oTable.fnGetPosition(this);
// var aPos = oTable.fnGetPosition($("thead tr").index(this));
$.fn.removeCol = function (col) {
if (!col) { col = 1; }
$('tr td:nth-child(' + col + '), tr th:nth-child(' + col + ')', this).remove();
return this;
};
$('#sampleTable').removeCol(aPos);
}
});
});
AccountType AccountName
New Name1 Lead Name2 test Name3
here my requirement is removing a column from data table using drag and drop on treeview ;i am unable to get the column Index here;please guide me how to acheive this;If i need any api's guide me how to add it;here is my code:
@import "../DataTabels/demo_table.css";
debugger;
$(document).ready(function () {
$(".treeNode").draggable({ helper: 'clone' });
$("#droppable").droppable({
drop: function (event, ui) {
var columnName = $(ui.draggable).text();
var mytable = $("#sampleTable").dataTable(),
iter = 0;
//adding dragged treeview Node as column in data table
mytable.find('tr').each(function () {
var trow = $(this);
if (trow.index() === 0) {
trow.append('' + columnName + '');
}
else if (trow.index() >= 1) {
trow.append(' Acer ');
}
iter += 1;
});
var oTable = $("#sampleTable").dataTable();
oTable.fnDestroy();
//displaying Data
$("#sampleTable").dataTable();
}
});
});
$(document).ready(function () {
$("#sampleTable tr ").draggable({
cursor: 'move',
stack: $('#TreeviewDiv')
});
$("#TreeviewDiv").droppable({
drop: function (event, ui) {
var oTable = $("#sampleTable").dataTable();
//when i dropped on treeview Data Table column has to be delete.
//getting position of column
var aPos = oTable.fnGetPosition(this);
// var aPos = oTable.fnGetPosition($("thead tr").index(this));
$.fn.removeCol = function (col) {
if (!col) { col = 1; }
$('tr td:nth-child(' + col + '), tr th:nth-child(' + col + ')', this).remove();
return this;
};
$('#sampleTable').removeCol(aPos);
}
});
});
AccountType AccountName
New Name1 Lead Name2 test Name3
This discussion has been closed.