2013-10-20 129 views

回答

3

問題描述中的措詞聽起來有點偏離您的問題標題,但我認爲您要求的是如何僅通過選擇器列中的複選框選擇行。您可以使用Selection mixin與selectionMode: 'none'的組合以及使用selector列插件的列來完成此操作。這裏有一個粗略的例子:

require([ 
    'dojo/_base/declare', 
    'dgrid/Grid', 
    'dgrid/Selection', 
    'dgrid/selector' 
], function (declare, Grid, Selection, selector) { 
    var SelectionGrid = declare([Grid, Selection]); 
    var grid = new SelectionGrid({ 
     columns: { 
      selector: selector({ label: '' }), 
      // other columns here... 
     }, 
     selectionMode: 'none' 
    }); 
    // Place, startup the grid, and add data here... 
}); 

你可以看到dgrid的test/selector.html頁面像這樣的例子。

+0

感謝您的好回答肯。 none模式真的解決了這個問題。 發生的另一個問題是,在將網格cellNavigation更改爲false後,網格停止對單擊的單元格進行聚焦,但它將整個行聚焦。這是爲什麼? – Tarek

+0

按照定義,'cellNavigation'設置爲'false'的確可以改變'Keyboard' mixin的行爲,使它專注於行級別而不是單元級別。你可以通過混合使用'Selection'而不是'CellSelection'來對行選擇進行類似的選擇(這對於'selector'來說通常更合適)。 –

+0

將cellNavigation設置爲false後面的想法,因此我可以在標題中使用選擇小部件(由'renderHeaderCell'創建),因爲當我處於false模式時,它不會打開下拉菜單。 只是當我在一個真正的cellNavigation它打開。使用cellSelection的 也不允許。 – Tarek