SelectAll ChildRow with in group
Hi All,
Is there an option to select all child rows with in the grouped column

Please check the highlighted area in the image, When ever user clicks there all the child rows under that should be selected.
Let me know if this can actually be an enhancement it would be a wonderful feature to the grid where user can group the columns and select child rows i.e. selectAll under each column and perform desired operations.
Am doing something similar using this : $scope.gridOptions1.onRegisterApi = function (gridApi) { $scope.gridApi = gridApi; $scope.gridApi.selection.on.rowSelectionChanged($scope, function (row) {
if(row.internalRow==true && row.isSelected==true){
var childRows = row.treeNode.children;
for (var j = 0, length = childRows.length; j < length; j++) {
var rowEntity = childRows[j].row.entity;
$scope.gridApi.selection.selectRow(rowEntity);
}
}
if(row.internalRow==true && row.isSelected==false){
var childRows = row.treeNode.children;
for (var j = 0, length = childRows.length; j < length; j++) {
var rowEntity = childRows[j].row.entity;
$scope.gridApi.selection.unSelectRow(rowEntity);
}
}
});
}
I have also achieved this by using the below functions :
$scope.gridOptions1.onRegisterApi = function (gridApi) { $scope.gridApi = gridApi; $scope.gridApi.selection.on.rowSelectionChanged($scope, function (row) { if(row.internalRow==true && row.isSelected==true){ var childRows = row.treeNode.children; for (var j = 0, length = childRows.length; j < length; j++) { selectAllChildren($scope.gridApi,childRows[j]); } }
if(row.internalRow==true && row.isSelected==false){
var childRows = row.treeNode.children;
for (var j = 0, length = childRows.length; j < length; j++) {
unSelectAllChildren($scope.gridApi,childRows[j]);
}
}
});
}
function selectAllChildren(gridApi,rowEntity){
if(rowEntity.children.length==0){
gridApi.selection.selectRow(rowEntity.row.entity);
}else{
var childrens = rowEntity.children;
for (var j = 0, length = childrens.length; j < length; j++) {
selectAllChildren(gridApi,childrens[j]);
}
}
}
function unSelectAllChildren(gridApi,rowEntity){
if(rowEntity.children.length==0){
gridApi.selection.unSelectRow(rowEntity.row.entity);
}else{
var childrens = rowEntity.children;
for (var j = 0, length = childrens.length; j < length; j++) {
unSelectAllChildren(gridApi,childrens[j]);
}
}
}
+1 on having this feature enabled. Was there a specific reason this feature was disabled?
"Group header rows cannot be edited, and if using the selection feature, cannot be selected. "
+1
+1
+1
+1
+1
+1
+1
How can I select gropu level and travers all children?
+1 why not merged to master?
+1
Hey, guys, I tried listed above code and it won't working.
Seems UI-grid API has changed.
So I have achieved this with the next code:
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
$scope.gridApi.selection.on.rowSelectionChangedBatch($scope, function (rows) {
rows.forEach(childRow => $scope.proceedParentSelection(childRow));
});
$scope.gridApi.selection.on.rowSelectionChanged($scope, function (row) {
$scope.proceedParentSelection(row);
});
$scope.proceedParentSelection = function(childRow) {
let parentRow = childRow.treeNode.parentRow;
parentRow.isSelected = parentRow.treeNode.children.every(child => child.row.isSelected)
}
}
`
I don't recommend to use gridApi.selection.unSelectRow or gridApi.selection.selectRow, because they will call toggleRowSelection(), which will also raise rowSelectionChanged(), so I prefered to use GridRow.prototype.setSelected(boolean) to select or un select row