Есть 2 сетки grid1 grid2. Мое требование: когда я выбираю строку в grid1, grid2 должен обновляться. Я могу получить измененные данные на основе выбора строки из моей службы, но я не могу ее отобразить на моей grid2. Я попыталсяУгловая ui-сетка: как обновить 2-ю сетку на основе строки выбранного значения 1-й сетки
$scope.grid2 = function() { $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL);
$scope.gridApi.core.refresh();}
Как выше в случае RowSelectionChanged внутри СЕТКА1 onRegisterAPI
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
$timeout(function() {
$scope.gridApi.selection.on.rowSelectionChanged($scope, function (row) {
$scope.value = row.entity.MVE_VEID;
console.log($scope.value);
$scope.contractvalues = contracts.query({ id: $scope.value });
console.log($scope.contractvalues);
$scope.gridoptions2 = function() { $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL); $scope.gridApi.core.refresh(); }
$scope.refresh = true;
});
Как я могу обновить данные в СЕТКА2?
Текущий код: contrcontroller.js
<pre>
angular
.module('VendorApp')
.controller('ang_contcontroller', ang_contcontroller);
ang_contcontroller.$inject = ['$scope','contracts'];
function ang_contcontroller($scope, contracts) {
$scope.contractvalues = contracts.query({ id: $scope.value });
$scope.gridoptions2 = {
enableRowHeaderSelection: false,
multiSelect: false,
enableRowSelection: true,
enableSelectAll: true,
enableSorting: true,
enableFiltering: true,
enablePagination: true,
enablePaginationControls: true,
paginationCurrentPage: 1,
paginationPageSize: 100,
maxVisibleColumnCount: 200,
columnDefs: [
{ name: 'CONTRACTID', field: 'MCO_COID' },
{ name: 'NAME', field: 'CO_DESC' },
{ name: 'VENDORID', field: 'MCO_VEID' }
],
data: $scope.contractvalues
};
$scope.gridoptions2.onRegisterApi = function (gridApi) {
$scope.gridApi2 = gridApi;
}
}
vencontroller.js
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
$timeout(function() {
$scope.gridApi.selection.on.rowSelectionChanged($scope, function (row) {
$scope.value = row.entity.MVE_VEID;
console.log($scope.value);
$scope.contractvalues = contracts.query({ id: $scope.value });
console.log($scope.contractvalues);
$scope.gridoptions2 = {};
$scope.gridoptions2.data = $scope.contractvalues;
//$scope.gridApi2.refresh();
$scope.grid2 = function() {
$scope.gridApi2.core.notifyDataChange(uiGridConstants.dataChange.ALL);
$scope.gridApi2.core.refresh();
};
//$scope.grid2 = function() {
// $scope.gridoptions2 = angular.copy($scope.gridoptions2);
// $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL= function() { $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL); },$scope.gridApi.core.refresh(););
// }
//$scope.refresh();
//$scope.gridoptions2 = function() { $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.ALL); }
});
});
<code>
попытайтесь обновить свой столбец данными, он будет работать – Manish
Я пробовал это уже, не работал. – RajaniR
Как это сделать? обновить columndef с данными? Я обновляю свой вопрос с помощью моего текущего кода – RajaniR