2015-06-29 62 views
9

我有一個問題,讓我把它放在我的掠奪者的例子中,我想知道爲什麼我的$scope.revertSelection()函數無法正常工作。 [http://plnkr.co/edit/3KXrUuCsSACuhefmyzxN?p=info][1]如何以編程方式在Ui.grid angularJs中選擇一行?

步驟:

1)由名稱排序右手網格(降序)

2)選擇3-4行隨機

3)點擊 '複印' 按鈕所有入圍行由名稱複製到$scope.retainSelection

4)分類的右手網格(升序)

5)點擊「恢復」按鈕(這是行不通的)

我期待在步驟2)中選擇以前選擇的所有行,這不會發生:-(請幫我解決這個問題。 我使用Google搜索,但無法找到gridApi.selection的任何文檔以查找其他方法來滿足我的要求。

注:我使用Ui.grid不NG-電網

問候,

+0

你好,你有這個工作嗎? –

回答

13

我應該使用...

$scope.gridApi.grid.modifyRows($scope.gridOptions.data); 
$scope.gridApi.selection.selectRow($scope.gridOptions.data[i]); 

...而不是...

$scope.gridApi.selection.selectRow(i); 

我的朋友給了link to docs

+2

您需要在'selectRow'之前調用'modifyRows'$ scope.gridApi.grid.modifyRows($ scope.gridOptions.data);'[https://github.com/angular-ui/ui-grid /issues/2267](https://github.com/angular-ui/ui-grid/issues/2267#issuecomment-128551701) –

+0

我可以在沒有'modifyRows'的4.0.6版本的'selectRow' – Guus

相關問題