Titanium删除TableViewRow,model-view绑定应该会自动反映tableview [英] Titanium delete TableViewRow, model-view binding should automatically reflect tableview
问题描述
这就是我在 tableview (android) 的 longclick 事件上删除 tableviewrow 的方法$.tableview.deleteRow(e.index);,但这只会删除该行.我如何还删除 tableviewrow 上的数据,这将通过模型 id 从集合中删除它,并且模型视图绑定应该自动在 tableview 中反映这一点.有任何想法吗?谢谢.
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.
推荐答案
您需要从集合中删除模型对象,然后会触发相应的事件来更新表.
you need to delete the model object from the collection which will then trigger the appropriate events to update the table.
所以在你的长按事件中
$.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
这篇关于Titanium删除TableViewRow,model-view绑定应该会自动反映tableview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!