我在理解通過ui-grid可用的屬性/功能時遇到了一些困難。我經常對它以前的版本ng-grid感到困惑。我試圖找到刪除檢查條目的最佳方法。這裏是我的標記,但由於不是很理解,如果我有一個索引,或者通過連續的實體數可供選擇:如何正確刪除所選項目ui.grid Angular JS
HTML:
<div class="form-group">
<button type="button" id="addData" class="btn btn-success" ng-click="addData()">Add Data</button>
<button type="button" id="removeData" class="btn btn-success" ng-click="removeData()">Remove First Row</button>
<br>
<br>
<div id="grid1" ui-grid="gridOptions" ui-grid-edit ui-grid-selection external-scopes="myViewModel" class="grid"></div>
</div>
說謊我的控制之下:
$scope.removeData = function() {
console.log($scope.gridApi.selection.getSelectedRows());
var items = $scope.gridApi.selection.getSelectedRows();
angular.forEach($scope.myData, function (data, index) {
angular.forEach(items, function (item) {
if (item.displayValue = data.displayValue)
{
$scope.myData.splice(index, 1);
}
});
其中displayValue
是我的專欄的一個屬性,$scope.myData
是我的數據。是否有其他方式將選擇發送給控制器以進行刪除?目前的方式我不知道(顯然)。任何幫助將不勝感激。如果我的標記不完整,我會根據需要更新它。謝謝!
在一個側面說明,如果你可以使用LO-破折號,這能給你一些更好的工具來使用集合。 – 2014-12-10 01:15:05
你也可以建議我們如何從數據庫中刪除這個值。我的意思是我們如何才能進行刪除服務電話 – Dileep 2016-05-17 15:00:40
要回答dileep的查詢,請參閱下面(這裏沒有足夠的空間)。 – 2016-08-12 13:06:01