我想顯示一個列擴大的UI網格而不是一個子網格的擴張 當用戶單擊該行的擴展圖標,而不是顯示我想要顯示列表視圖的子網格,我可以到達可以在一行中調用靜態列表視圖但無法傳遞相關數據的點一行到列表角度Ui網格顯示在行擴展列表視圖不是一個子網格,並通過選定的行ID和數據
下面是工作plunker http://plnkr.co/edit/PZL6UfWmg2h00sw36FTk?p=preview
這是我的控制器:
angular.module('availability',['ui.grid', 'ui.grid.expandable', 'ui.grid.selection', 'ui.grid.pinning','angular.filter'])
angular.module('availability').controller('Availability.CTRL',
['$scope','$log','$rootScope',
function($scope,$log,$rootScope){
var weeklyAvailability = {};
$scope.gridOptions = {
expandableRowTemplate: 'availability.detailed.view.tpl.html',
expandableRowHeight: 150,
expandableRowScope: {
rowIdToBePassed : weeklyAvailability
},
columnDefs: [
{ field: 'email' }
],
onRegisterApi: function (gridApi) {
gridApi.expandable.on.rowExpandedStateChanged($scope, function (row) {
if (row.isExpanded) {
//The Below will come from the server once I get the id of the worker in the selected row
var testData = [
{
"availabilityDate": "2015-04-01T04:18:51.080Z",
"availabilityDay": "Wednesday",
"availabilityStartTime": "2015-04-01T05:18:51.105Z",
"availabilityEndTime": "2015-04-02T03:18:51.110Z",
"available": false,
"id": "551b71d8921933a6cbc90495",
"workerId": "5500d45b1d1dff783e895f72"
},
{
"availabilityDate": "2015-04-01T04:18:51.080Z",
"availabilityDay": "Wednesday",
"availabilityStartTime": "2015-04-01T06:18:51.105Z",
"availabilityEndTime": "2015-04-01T05:18:51.110Z",
"available": false,
"id": "551b71d8921933a6cbc90496",
"workerId": "5500d45b1d1dff783e895f72"
}
];
//I want to pass the data I receive from the server to the expanded scope
//The below subData is present in availability.detailed.view.tpl.html
//Cant figure out a way to pass the testData field to subData
$scope.subData = testData;
//row.entity.weeklyAvailability.data = testData;
}
});
}
};
var workers = [
{
"email": "[email protected]",
"id": "5500d45b1d1dff783e895f72"
},
{
"email": "[email protected]",
"id": "550368c058b17f6ca096e397"
}
]
$scope.gridOptions.data = workers;
}]);
非常感謝它工作順利,抱歉不能upvote還沒有:( – 2015-04-02 18:33:58
@ c0bra我有同樣的問題,但在子數據我想根據行Id填充不同的數據或東西,每distingue行,一旦我點擊我需要顯示描述或作者等特定行的詳細信息 意思是我點擊時想顯示該行的其他信息 您能否建議我該如何實現這一目標? – 2016-10-05 11:58:17