Inline Editing: Can't get updated value on blur event
Inline Editing: Can't get updated value on blur event
Hi All,
So after a user updates the inline editing input on my data table, I need to get the new value of what the user has entered so I can pass the resulting updated object to the preSubmit handler. But on blur, I can only get the original value. How do I get the updated value ?
Below is the code and some comments for more clarity (hopefully) . Thanks in advance for the help !
editor.inline(this, {
onBlur: function(e) {
console.log("UPDATED CELL IS:");
// Now I try and get the user updated value of the input we have blurred away from:
console.log(trade_browser_results_table.cell(current_td).data());
// The above only gets the original data, not the updated version
// But the following method DOES get the updated cell value:
let target_id = '#' + e.s.setFocus.s.opts.id; // this is the ID of the edited input, not the td cell
// The problem is, we are not supposed to use the "s" object, as it's private to Datatables !
let updated_cell_value = $(target_id).val();
// So now what ?
$current_edited_row = $(target_id).closest('tr');
updated_target_column = current_td.data("cell-col");
current_edited_row = trade_browser_results_table.row( current_row_index ).data();
//For whatever reason, if the user has deleted the data cell, revert it to the original value and don't submit.
if(updated_cell_value == ''){
editor.close();
revert_cell(current_td, selected_trade_attribute, target_id, $current_edited_row, current_row_index);
}
else {
current_edited_row[selected_trade_attribute] = updated_cell_value;
editor.submit();
}
if ($current_edited_row.find('.cell_to_update').length < 1) {
$current_edited_row.removeClass('row_staged_for_edit');
}
if (!trade_browser_results_table.rows('.row_staged_for_edit').any()) {
$("#update_trades").prop('disabled', true);
}
else {
$("#update_trades").prop('disabled', false);
}
},
onComplete: 'close'
});
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
Hi,
I'm not seeing an Editor license for your account and it looks like your trial ran out in June. Could you confirm your licensed account so I can make sure our records are correct please?
Regarding your question - you would use
field().val()
to get the value from the form.Allan