我在添加所有者网格配置中有$scope.addProcessOwner
功能,当用户点击每个所有者时我正在使用selectedOwners
创建新的数组对象,现在我想将selectedOwners
设置为所选的数据源所有者网格。
1-如何将selectedOwners
设置为selectedOwnerGridOptions
的数据源?
2-如果从添加所有者网格中选择所有者后,如何刷新所选所有者网格?
grid.html
添加所有者
<div kendo-grid="ownerSearch" options="ownerSearchResultGrid"
k-rebind="getOwnerSearchResultGrid"></div>
选择所有者
<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();
};
答案 0 :(得分:0)
而不是:
$scope.selectedOwnerGrid = selectedOwners;
$scope.selectedOwnerGridOptions.dataSource.read();
试试这个:
$scope.selectedOwnerGridOptions.dataSource.data(selectedOwners);