2012-01-17 42 views
0

我正在使用Ext.view.View爲我的數據視圖。當我選擇一個項目'selectionchange'事件觸發器兩次。但沒有「multiSelect:true」,它只會觸發一次。Extjs4 Ext.view.View selectionchange事件觸發twise當選擇項目

Ext.define('myViewView', { 
    extend: 'Ext.view.View', 
    alias: 'widget.myViewView', 
    store: myContentStore, 
    cls: 'content-view-view', 
    tpl: myContentViewTpl, 
    multiSelect: true, 
    trackOver: true, 
    overItemCls: 'x-item-over', 
    itemSelector: '.thumb-wrap', 
    emptyText: emptyDataText, 
    resizable: true, 
    style: { 
     overflow: 'auto' 
    }, 
    listeners: { 
     selectionchange: function(dv, selections) { 

     } 
    }, 
    prepareData: function(data) { 
     Ext.apply(data, { 
      sizeString: Ext.util.Format.fileSize(data.size), 
      modifiedString: Ext.util.Format.date(data.modified, "m-d-Y:g-i-a"), 
      fileFormatPath: createBreadCrumb(data.filePath, false) 
     }); 
     return data; 
    } 

}); 

回答

2

只有當您選擇其他內容時(例如,您選擇了一行並且您選擇了另一行),它纔會觸發兩次。第一個事件是由於您取消選擇第一行而引發的,第二個事件是在真正選擇其他行後觸發的。 最簡單的解決方案是爲事件處理程序設置緩衝區。

例子:

listView.on('selectionchange', function(view, nodes){ 
    // handler 
}, this, { buffer: 10 }); 

listeners: { 
    selectionchange: function() { 
     // handler 
    }, 
    buffer: 10 
} 
+0

感謝you.Its偉大的工作。 – jeewiya 2012-01-18 03:34:41

相關問題