0
最初の行で$scope
にgrid.appScope
でアクセスできます。 しかし、第2レベルの行には、grid.appScope
が返す手がかりがあります。
2番目のレベルの行の列にチェックボックスがあります。ユーザーがクリックすると、メソッドを呼び出す必要があります。最初のレベルの行では、私はその後columndef
に、私は私が第2レベルの行に同様の操作を行うにはどうすればよいng-click="grid.appScope.update_field
...
を追加
以下$scope.update_field = function...
のように行うことができますか?
コードは今、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;
});
}
申し訳ありませんが、あまりにも一般的です。 – Naigel
ありがとう、サンプルコードが追加されました。 –