In the Add owner grid configuration, I have a function called $scope.addProcessOwner
. When a user clicks on each owner, a new array object is created with the data stored in selectedOwners
. Now, I want to set selectedOwners
as the dataSource of the selected owner grid.
1- How can I set selectedOwners
as the dataSource of selectedOwnerGridOptions
?
2- How can I refresh the selected owner grid once an owner is selected from the Add owner grid?
grid.html
Add owner
<div kendo-grid="ownerSearch" options="ownerSearchResultGrid"
k-rebind="getOwnerSearchResultGrid"></div>
Selected owner
<div kendo-grid="selectedOwner" options="selectedOwnerGridOptions" k-data-source="selectedOwnerGrid"></div>
Ctrl.js
var selectedOwners = [];
$scope.addProcessOwner = function(dataItem){
var selectedOwner = {
fullName: dataItem.fullName,
workerKey: dataItem.workerKey,
stdId: dataItem.stdId,
workEmailAddressText: dataItem.workEmailAddressText
};
var isExists = function(e) {
if (e.fullName === selectedOwner.fullName && e.workerKey === selectedOwner.workerKey) {
return true;
}
};
if (!selectedOwners.some(isExists)) {
selectedOwners.push(selectedOwner);
}
console.log('WORKER DATA',JSON.stringify(selectedOwners));
$scope.selectedOwnerGrid = selectedOwners;
$scope.selectedOwnerGridOptions.dataSource.read();
};