Titanium delete TableViewRow, model-view binding should automatically reflect tableview

纵饮孤独 提交于 2020-01-15 12:33:17

问题


This is how I delete a tableviewrow on a longclick event of a tableview (android) $.tableview.deleteRow(e.index); , but this just removes the row. How do I also remove the data on my tableviewrow which will in turn remove it from collection via model id, and model-view binding should automatically reflect this in tableview.Any Ideas?Thank You.


回答1:


you need to delete the model object from the collection which will then trigger the appropriate events to update the table.

So in your longpress event

$.tableview.deleteRow(e.index);
collection.models[e.index].destroy() // should delete model, use index to get model
                                     // from the collection

collection.fetch();                  // should force table to update


来源:https://stackoverflow.com/questions/17419483/titanium-delete-tableviewrow-model-view-binding-should-automatically-reflect-ta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!