Reputation: 436
I'm using tabulator.js which every time a user edit a cell (cellEdited:function
) it calls a function to store the specific value to db and after that it refreshes (reload) the entire table.
What i'm willing to do is to keep both row and column index into a variable before save. After tabulator refreshes, will apply cell focus at the specific cell was before.
Is there any function to directly access cell's value? like tableName.setValue(rowId, ColId, value);
my typical table setup is:
function setup_table(dataset){
table = new Tabulator(document.getElementById("qc_table"), {data:dataset,layout:"fitColumns",addRowPos:"bottom",index:"ID",
keybindings:{"navNext" :'tab("9")'},
columns:[{title: "ID", field: "ID", headerSort:false, width: 80},
{title: "title1", field: "f1",width: 80,editor:"input"},
{title: "title2", field: "f2",width: 80,editor:"input"},
{title: "title3", field: "f3",width: 80,editor:"input"}],
cellEdited:function(cell){
// -- HERE GET ROW INDEX AND COLUMN INDEX BEFORE SAVE--
// SAVE TABLE TO DB
saveTable().then(function(done){
// CODE TO REFRESH TABLE
// -- HERE APPLY FOCUS TO THE PREVIOUS EDITED CELL --
});
}
});
}
Any ideas? Thanks for your time!
Upvotes: 0
Views: 1159
Reputation: 8348
There should be no need to refresh the table, you can simply call the setValue function on the Cell Component passed into the cellEdited
callback.
cellEdited:function(cell){
// SAVE TABLE TO DB
saveTable().then(function(done){
cell.setValue("whatever value you want")
});
}
Upvotes: 2