1

我正在尝试在行单击时展开和折叠分组,因为它应该与 ui 网格中的 + 和 - 图标一起使用。

我正在尝试从下面的行模板中调用 treeButtonClick(row, $event) 。但没有触发的功能。

rowTemplate: '<div ng-click="treeButtonClick(row, $event)" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" class="ui-grid-cell" ng-class="col.colIndex()" ui-grid-cell></div>',

在 ui 网格中分组时,这也应该与 + 和 - 图标相同。

请建议我如何使它工作,在此先感谢

4

2 回答 2

1

解决方案是:
1. 为您的表格创建自定义模板:

<div ng-mousedown="grid.appScope.onMouseDown(row, $event)"
     ng-click="grid.appScope.onDblClickRow(row.entity)" grid="grid" class="ui-grid-row">
    <div ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name"
         class="ui-grid-cell" ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader, custom: true }"
         ui-grid-cell></div>
</div>

指定要用作 rowTemplate 的模板和您自己的应用范围提供程序:

vm.gridOptions = {
            appScopeProvider: myAppScopeProvider,
            rowTemplate: 'app/pages/components/building/buildReqViewAll/rowTemplate.html',
            onRegisterApi: function (gridApi) {
                vm.gridApi = gridApi;
            }
        };

并打开您的行的功能:

var myAppScopeProvider = {
            onClickRow: function (row, event) {
                var rowIndex = row.grid.renderContainers.body.visibleRowCache.indexOf(row);

                if (!angular.isUndefined(row.treeLevel)) {
                    vm.gridApi.treeBase.toggleRowTreeState(vm.gridApi.grid.renderContainers.body.visibleRowCache[rowNumber]);
                }
            }
        };
于 2016-12-23T11:30:44.063 回答
0

你可以使用下面的函数来展开所有行,$scope.gridApi.treeBase.expandAllRows(),同样的折叠方式你可以使用collapseAllRows。您可以为该列添加一个 cellTemplate,其中您需要“+”和“-”,对于“+”单击,您可以通过这些函数扩展这些行。

于 2016-10-06T23:56:03.403 回答