I think I’ve discovered a bug, or, at least, a strange behaviour with Datatable combined with DataCollection.
// models/applications
export const dataApplications = new webix.DataCollection({
url: "/applications",
save: "rest->/applications"
});
If you look at the code below, the SCENARIO 1 will work properly:
- data edited in the datatable is pushed to the db
- date deleted from the datatable is removed from the db
SCENARIO 2 (we use the parameter ‘data’ instead) :
- data edited in the datatable is pushed to the db
- data deleted from the datatable is NOT removed from the db, so, if I reload the datatable, the deleted record comes back in place… (actually, I checked and there is no ajax request sent in the debugger)
// views/applications
import { JetView } from "webix-jet";
// import { dataApplications } from "models/applications"; <= SCENARIO 2
export default class ViewAccountAppsTable extends JetView {
config() {
return {
id: "grid-applications",
view: "datatable",
url: "/applications", // <= SCENARIO 1: we use 'url'
save: "rest->/applications", // <= and 'save' params
editable: true,
editaction: "dblclick",
select: "row",
// data: dataApplications, // <= SCENARIO 2 : we use 'data'
columns: [
{....some columns.....},
// Delete button
{ header: "Delete", template:
function(obj) {
return "<div class='delete_app'>
<button class='webixtype_base'>
Delete
</button>
</div>"
}
}
],
onClick: {
"delete_app": function(event, id, node) {
this.remove(id);
}
}
}
}
To remove the record, I’ve also tried other syntax, but same behavior in the end (the record is NOT deleted from the db if I use the DataCollection):
//$$("grid-applications").remove(id);
//$$("grid-applications").remove($$("grid-applications").getSelectedId());