天天看點

[Sencha ExtJS6 Modern] 改進bug: 當store.remove/removeAt執行之後,DataView的對應item的dom沒有移除

原文位址:http://blog.csdn.net/lovelyelfpop/article/details/51853285

ExtJS 版本:

Ext 6.0.2.437 Modern

描述:

一個dataview,綁定一個store,  執行了store.remove/removeAt方法之後,dataview中的對應item的dom元素并沒有移除

預期現象:

被删除的record的對應的dom元素應該要被删除的

此現象可以看這個示例:

https://fiddle.sencha.com/#fiddle/1d7k

原因:

'Ext.dataview.DataView' 類中,方法 'onStoreRemove' 的'indices' 參數實際是個整型, 但是在函數體内卻使用了索引,明顯不對.

onStoreRemove: function(store, records, indices) {
    var container = this.container,
        ln = records.length,
        i;
    for (i = 0; i < ln; i++) {
        container.moveItemsToCache(indices[i], indices[i]); //這裡
    }
},
           

改為:

onStoreRemove: function(store, records, indices) {
    var container = this.container,
        ln = records.length,
        i;
    for (i = 0; i < ln; i++) {
        container.moveItemsToCache(indices + i, indices + i); //這裡
    }
},
           

現在可以了,看這個例子:

https://fiddle.sencha.com/#fiddle/1d7n

歡迎加入Sencha Touch + Phonegap交流群

1群:194182999 (滿)

2群:419834979

共同學習交流(部落客QQ:479858761)