Skip to content

Commit

Permalink
Merge pull request #2301 from kevin-sage/expandable-doc
Browse files Browse the repository at this point in the history
Load Data on Row Expanded
  • Loading branch information
PaulL1 committed Dec 14, 2014
2 parents c9a4c0f + 54f0ef6 commit eee7035
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions misc/tutorial/306_expandable_grid.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,42 @@ SubGrid nesting can be done upto multiple levels.
$scope.gridOptions.data = data;
});
}]);

app.controller('ThirdCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) {
$scope.gridOptions = {
expandableRowTemplate: 'expandableRowTemplate.html',
expandableRowHeight: 150,
onRegisterApi: function (gridApi) {
gridApi.expandable.on.rowExpandedStateChanged($scope, function (row) {
if (row.isExpanded) {
row.entity.subGridOptions = {
columnDefs: [
{ name: 'name'},
{ name: 'gender'},
{ name: 'company'}
]};

$http.get('/data/100.json')
.success(function(data) {
row.entity.subGridOptions.data = data;
});
}
});
}
}

$scope.gridOptions.columnDefs = [
{ name: 'id', pinnedLeft:true },
{ name: 'name'},
{ name: 'age'},
{ name: 'address.city'}
];

$http.get('/data/500_complex.json')
.success(function(data) {
$scope.gridOptions.data = data;
});
}]);
</file>
<file name="index.html">
<div ng-controller="MainCtrl">
Expand All @@ -114,6 +150,10 @@ SubGrid nesting can be done upto multiple levels.
<div ng-controller="SecondCtrl">
<div ui-grid="gridOptions" ui-grid-pinning ui-grid-expandable ui-grid-selection class="grid"></div>
</div>
Retrieve data for subGrid when expanding
<div ng-controller="ThirdCtrl">
<div ui-grid="gridOptions" ui-grid-expandable class="grid"></div>
</div>
</file>
<file name="main.css">
.grid {
Expand Down

0 comments on commit eee7035

Please sign in to comment.