Skip to main content

This is weird. I have a abandonRows()  followed by model.save() in javascript. It seems to work from the UI. That is the table list is refreshed and from the console, it shows the data is removed. But it is actually not delete from the database. Is that correct?

Hi Jili. Looking at our API documentation, abandonRows() will remove an array of rows from a model without requesting that that the rows be deleted from the database. It sounds like you’re looking for the model.save() to save changes and delete the abandoned rows from the model. If that’s what you’re aiming for, I believe you would explicitly need to mark them for deletion, and then save the model changes. deleteRow() may be what you’re after - I would suggest experimenting with this in a safe non-critical environment and checking the API documentation for usage details. Also, undeleteRow() may be good to know about, if you want to undo the action of marking the row for deletion.


Thanks! Yes I read the documentation around that. It says it’s best to use abandonRows() for multiple rows. And call mod l.save after that to commit to the database. I did that but it’s not committing the deletion.

Are you saying I should call markrowfordeletion, deleteRow() then call save?


Hello Jili,

AbandonRows() - will empty your model, meaning it will sweep off all data including Id’s of records in model, in order to delete records from database, we need to supply Ids.
 
Try as shown below:

var $ = skuid.$;

$.each(myModel.getRows(), function(){    
      myModel.deleteRow(this);
});

myModel.save();


Hope this helps!


Using deleteRow instead of abandonRows worked. Thanks!


deleteRow() and model.save is the correct way to delete from database. Thanks.