最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular UI Grid conditional row expand - Stack Overflow

programmeradmin4浏览0评论

I'm using Angular UI Grid and the ui-grid-expandable plugin. Is there a way to decide for each row, if the expand button (+) is displayed? By default it is always displayed, no matter if there is available data in the subgrid.

Thanks.

I'm using Angular UI Grid and the ui-grid-expandable plugin. Is there a way to decide for each row, if the expand button (+) is displayed? By default it is always displayed, no matter if there is available data in the subgrid.

Thanks.

Share Improve this question asked Oct 12, 2015 at 13:46 user250773user250773 5791 gold badge8 silver badges21 bronze badges 1
  • may be getTreeState() but it seems not working: ui-grid.info/docs/#/api/ui.grid.treeBase.api:PublicApi – Asqan Commented Oct 13, 2015 at 9:10
Add a ment  | 

4 Answers 4

Reset to default 5

Sadly no, there is not an option for that as of now.

You can use the following to make things work as you wish:

  • remove default row headers by setting to false enableExpandableRowHeader
  • adding a custom row header by calling $scope.gridApi.core.addRowHeaderColumn

This way you can build your own logic. I did something like that in this plunkr.

If you need more info:

  • http://ui-grid.info/docs/#/tutorial/114_row_header
  • http://ui-grid.info/docs/#/tutorial/216_expandable_grid

I have a pull request with UI-GRID that solves this.

You add a boolean to the subGridOptions called disableRowExpandable.

https://github./angular-ui/ui-grid/pull/6135/mits/83ade3445711e532f689d224904babfe92c7b45e

Yes you can !

Add to subGridOptions object this option:

disableRowExpandable:(condition here).

Just use the last version of UI GRID

https://cdnjs.cloudflare./ajax/libs/angular-ui-grid/4.11.0/ui-grid.min.js

Then use the property disableRowExpandable inside your subGridOptions

Here there a little example.

for (i = 0; i < response.data.result.length; i++) {
                    if (response.data.result[i].SubProcesos != null) {
                        response.data.result[i].subGridOptions = {
                            columnDefs: establecerColDefs(response.data.Rol),
                            data: response.data.result[i].SubProcesos,
                            disableRowExpandable: false

                        };
                    } else {
                        response.data.result[i].subGridOptions = {
                            columnDefs: [{ }],
                            data:[{}],
                            disableRowExpandable: true
                    };
                    }
                }

发布评论

评论列表(0)

  1. 暂无评论