如何使 Angular ui 网格最初扩展所有行? [英] How to make Angular ui grid expand all rows initially?

查看:20
本文介绍了如何使 Angular ui 网格最初扩展所有行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ui grid 来显示数据列表,并且我试图最初展开所有行.

I am using ui grid to show a list of data and I am trying to initially expand all rows.

我试图在 onRegisterApi 事件中执行此操作:

I am trying to do this in the onRegisterApi event:

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();

            }
        };

但是上面的代码不起作用.看起来当我调用 expandAllRows() 时,行还没有呈现.

But the code above does not work. It looks like when I call expandAllRows() the rows are not rendered yet.

推荐答案

我发现我可以使用 rowsRendered 事件展开所有行:

I find I can expand all rows by using rowsRendered event:

gridApi.core.on.rowsRendered(scope,() => {
        if (!gridApi.grid.expandable.expandedAll && !initialized)
        {
            gridApi.expandable.expandAllRows();
            initialized = true;
         }
});

我使用了一个初始化的变量来确定这是否是第一次呈现行,因为我最初只想展开所有行.

I have used a variable initialized to identify if this is the first time rows are rendered as I only want to expand all rows initially.

这篇关于如何使 Angular ui 网格最初扩展所有行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆