我正在使用ui grid来显示数据列表,我正在尝试初始扩展所有行.
我试图在onRegisterApi事件中执行此操作:
scope.GridOptions = { data: properties,columnDefs: [ { name: "Full Address",field: "FullAddress" },{ name: "Suburb",field: "Suburb" },{ name: "Property Type",field: "PropertyType" },{ name: "Price",field: "Price",cellFilter: 'currency'},{ name: "Status",field: "Status" },{ name: "Sale Type",field: "SaleType" },{ name: "Date Created",field: "CreateDate",cellFilter: "date:'dd/MM/yyyy HH:mma'"} ],expandableRowTemplate: 'template.html',expandableRowHeight: 200,onRegisterApi: (gridApi) => { scope.gridApi = gridApi; gridApi.expandable.on.rowExpandedStateChanged(scope,(row) => { if (row.isExpanded) { this.scope.GridOptions.expandableRowScope = row.entity; } }); gridApi.expandable.expandAllRows(); } };
就我而言,以下工作:
原文链接:https://www.f2er.com/angularjs/141301.html$scope.gridOptions = { ... onRegisterApi: function(gridApi) { $scope.gridApi = gridApi; $scope.gridApi.grid.registerDataChangeCallback(function() { $scope.gridApi.treeBase.expandAllRows(); }); } };