How to get the updated data handsontable table?

Tags: #<Tag:0x00007efc6042fa50>

There is a table of data. There is a script to filter columns, selecting the checkbox to the column name is removed from the table or there depending on check box or not. Here is the code:

var HIDDING_ROWS = [];

var show = function () {
var hot = $("#exempel").handsontable('getInstance');
var newColumns = $.extend(true, [], columns_personage);
var newHeaders = $.extend(true, [], header_personage);
for (var i = 0; i < HIDDING_ROWS.length; i++) {
    for (var j = 0; j < newColumns.length; j++) {
        if (HIDDING_ROWS[i] === newColumns[j].data) {
            newColumns.splice(j, 1);
            newHeaders.splice(j, 1);
        }
    }
}
hot.updateSettings({
    columns: $.extend(true, [], newColumns),
    colHeaders: $.extend(true, [], newHeaders)
});
hot.render();
};

$('.checkbox-inline input').change(function () {
var value = $(this).prop('checked');
var className = $(this).attr('class');
if (value) {
    HIDDING_ROWS.push(className);
    show();
}
else {
    var index = HIDDING_ROWS.indexOf(className);
    if (index < 0)return;
    HIDDING_ROWS.splice(index, 1);
    show();
}
});

After removal of the column I am trying to get the data in the table:

var row = $("#exempel").data('handsontable');
var tableData = row.getData();

And I get an object which has the properties which belong to the columns of which I deleted. How to get the data without the properties are retired (disappeared) from the table?

Hi @viktor.tsikalovskiy
I’m not sure what you mean my writing:

How to get the data without the properties are retired (disappeared) from the table?

You want to get cell’s data before it is deleted? If so you can use a beforeChange callback to gather data.

How do I remove column from the code of the table?

$(".testRemoveColl").change(function () {
    console.log($(this).val());
    var hot = $personageTable.handsontable('getInstance');
    hot.alter('remove_col', 10);
})

Uncaught Error: cannot remove column with object data source or columns option specified
how to fix

Hi @viktor.tsikalovskiy
Please check Remove cell for the demo solution