我想显示一个列扩大的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