如何使Angular ui网格最初基于数据扩展行?

Eri*_*ric 1 javascript angularjs angular-ui-grid

我正在使用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) => 
    {
        gridApi.expandable.expandAllRows();
    }
};
Run Code Online (Sandbox Code Playgroud)

问题是gridApi.expandable.expandAllRows()扩展所有分组部分.我看到有一个expandRow功能,但我不知道如何使用它来代替expandAllRows功能.我真的想扩展将列Status设置为特定值的组.有人可以帮我解决这个问题吗?

Sai*_*har 6

这是一种处理选择行扩展的方法.我创建了一个Plunker链接(http://plnkr.co/edit/CSaROQqKxYnkoxm2Tl6b?p=preview),我正在扩展所有偶数行.以类似的方式,您可以遍历数组并展开所需的行.

包括:
" $timeout"依赖于控制器

要扩展第一行:

$timeout(function() {
    var rows = $scope.gridApi.grid.rows;
    var entity = (rows.length && rows[0]) ? rows[0].entity : null;
    $scope.gridApi.expandable.toggleRowExpansion(entity);
  });
Run Code Online (Sandbox Code Playgroud)