在第一级行,我可以$scope
通过grid.appScope
. 但在第二级行中,我知道grid.appScope
返回的是什么。
我在二级行的列中有一个复选框,当用户点击时,我需要调用一个方法。在第一级行,我可以像下面这样
$scope.update_field = function...
然后在中columndef
,我添加ng-click="grid.appScope.update_field
...
我如何在第二级行做类似的事情?
下面是代码,现在checkfield
可以正常工作,但不能subcheckfield
正常工作。
controller('ctrlProductAssignment', function ($scope, $controller, $routeParams, api, libs, options, gui) {
$scope.update_field = function (rowEntity, colDef, newValue, oldValue) {
if (rowEntity.id > 0)
....
};
$scope.gridOptions = {
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
gridApi.expandable.on.rowExpandedStateChanged($scope, function (row) {
if (row.isExpanded) {
row.entity.subGridOptions = {
columnDefs: [
{ name: 'subcheckfield', displayName: 'Registered',
cellTemplate: '<input type="checkbox" ng-model="row.entity[col.name]" ng-click="grid.appScope.update_field(row.entity, { name:col.name }, row.entity[col.name], 0)">' },
]
};
api.raffle_productassignmentdetail.query({ raffle_id: $scope.deal.id, pa_id: row.entity.id }).$promise.then(function (response) {
row.entity.subGridOptions.data = response;
});
}
});
},
columnDefs: [
{ name: 'checkfield', displayName: 'Registered',
cellTemplate: '<input type="checkbox" ng-model="row.entity[col.name]" ng-click="grid.appScope.update_field(row.entity, { name:col.name }, row.entity[col.name], 0)">' },
]
};
api.raffle_productassignment.query({ raffle_id: $scope.deal.id, reseller_id: reseller_id }).$promise.then(function (response) {
$scope.gridOptions.data = response;
});
}