Get new cell value edited

Tags: #<Tag:0x00007f8b19ec83c0>

Hi al. I use handsontable for my app (slalary manage).

I have a problem when edited a cell value. After change value of cell hotElement.setDataAtCell(changes[index][0], col_total, json.total);, I want use console.log(hotElement.getDataAtCell(0, 9)) get new value cell edited, but is alway return old value.

Thank you!

afterChange: function (changes, source) {
    if (source === 'loadData' || source === 'populateFromArray' || changes[0][1] === 'total' || changes[0][1] === 'received' || changes[0][1] === 'holiday_salary') {
        return;
    }
    
    // khi thêm cột cần điều chỉnh lại chỉ số cột
    var col_total = 9; // chỉ số cột tổng lương
    var col_received = 12; // chỉ số cột thực nhận
    var col_holiday_salary = 6; // chỉ số cột lương ngày nghỉ, lễ
    
    $.each(changes, function(index){
        var rowThatHasBeenChanged = changes[index][0],
        columnThatHasBeenChanged = changes[index][1];
        var sourceRow = hotElement.getSourceDataAtRow(rowThatHasBeenChanged);
      
        $.ajax({
            url : script_name + '?' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=salary-content&save_change=1&month=' + $('#current-month').val() + '&nocache=' + new Date().getTime(),
            type : "POST",
            data : {
                save_change: 1,
                data : sourceRow
            },
            success : function(json) {
                hotElement.setDataAtCell(changes[index][0], col_total, json.total);
                hotElement.setDataAtCell(changes[index][0], col_received, json.received);
                hotElement.setDataAtCell(changes[index][0], col_holiday_salary, json.holiday_salary);
            }
        });                
    });
    
    hotElement.render();
    console.log(hotElement.getDataAtCell(0, 9))
	}

Hey @hongoctrien

to confirm, you would like to get a value while it is being typed (from an opened editor)?

1 Like

Thank for reply.
My example

Now, cell (0, 9) is 1000
I will set command

hotElement.setDataAtCell(0, 9, 2000); // set to 2000

After, I use getDataAtCell get new value (2000), but it alway get old value (1000)
My code

hotElement.setDataAtCell(0, 9, 2000); // set to 2000
hotElement.render();
console.log(hotElement.getDataAtCell(0, 9)) // it return old value, I want return new value

Thank you very mutch!

@aleksandra_budnik please help me.

Please share a demo. It is really hard to propose anything without an ability to debug it.