Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将子栅格添加到角度ui栅格子栅格_Javascript_Angularjs - Fatal编程技术网

Javascript 将子栅格添加到角度ui栅格子栅格

Javascript 将子栅格添加到角度ui栅格子栅格,javascript,angularjs,Javascript,Angularjs,我有一个工作的有角度的ui网格,带有用于扩展网格的html模板。 在此模板中还有另一个ui网格。 如何使子网格也可扩展? 第一个可扩展的网格工作得很好,第二个(subsub)ui网格不可扩展,但有数据) 如果您需要代码,请尝试以下非工作模式: var app = angular.module('app', ['ui.grid', 'ui.grid.expandable']); app.controller('MyCtrl', [ '$scope', '$http', '$log',

我有一个工作的有角度的ui网格,带有用于扩展网格的html模板。 在此模板中还有另一个ui网格。 如何使子网格也可扩展? 第一个可扩展的网格工作得很好,第二个(subsub)ui网格不可扩展,但有数据)

如果您需要代码,请尝试以下非工作模式:

var app = angular.module('app', ['ui.grid', 'ui.grid.expandable']);


app.controller('MyCtrl', [
    '$scope', '$http', '$log', '$templateCache', 'i18nService', '$interval', function($scope, $http, $log, $templateCache,  $interval) {


        $scope.gridOptions = {
            expandableRowTemplate: 'expandableRowTemplate.html',
            expandableRowHeight: 1400,
            expandableRowScope: {subGridVariable: 'subGridScopeVariable'},
            enableFiltering: true,
            treeRowHeaderAlwaysVisible: false,
            columnDefs: [
            { name: 'Col1',field:'Col1', width: '10%'  },
            { name: 'Col2', field: 'Col2'}
                       ],
            onRegisterApi: function(gridApi) {
                $scope.gridApi = gridApi;
                gridApi.expandable.on.rowExpandedStateChanged($scope, function(row) {
                    if (row.isExpanded) {
                        row.entity.subGridOptions = {
                            expandableRowTemplate: 'expandableRowTemplateSubgrid2.html',
                            expandableRowHeight: 700,
                            expandableRowScope: { subGridVariable: 'subsubGridScopeVariable' },
                            columnDefs: [
                                { name: 'SubCol1', field:'SubCol1', width: '10%' },
                                       { name: 'SubCol2', field: 'SubCol2' }
                            ],
                            onRegisterApi: function(subgridAPi) {
                                $scope.subgridAPi = subgridAPi;
                                subgridAPi.expendable.on.rowExpandedStateChanged($scope, function(row) {
                                    if (row.isExpanded) {
                                        row.entity.subsubGridOptions =
                                        {
                                            columnDefs: [
                                                { name: 'Testcol' },
                                                { name: 'TestCol2' }
                                            ]
                                        }
                                    }
                                });
                            }
                        };
                        $http.get('Path to webapi action to retrieve data')
                            .success(function(data) {
                                row.entity.subGridOptions.data = data;
                            });  
                    }

                });
            }
        };

我必须解决同样的问题。 下面是TypeScript中的代码:

protected doOnRegisterGridApiCore(gridApi: uiGrid.IGridApi) {
    this.gridApi = gridApi;
    gridApi.expandable.on.rowExpandedStateChanged(null, row => {
        if (row.isExpanded) {
            debugger;
            row.entity.subGridOptions = {
                expandableRowTemplate: defaultExpandableRowTemplate,
                expandableRowScope: row.entity,
                columnDefs: this.gridOptions.columnDefs,
                headerTemplate: '<div></div>',
                footerTemplate: '<div></div>',
                enableHorizontalScrollbar: 0,
                enableVerticalScrollbar: 0,
                onRegisterApi: (gridApi) => { this.doOnRegisterGridApi(gridApi); },
                enableExpandable: true,
                enableExpandableRowHeader: false,
                enableMinHeightCheck: false
            };
            this.treeGridFactory.get(row.entity)
                .then(data => {
                    debugger;
                    row.entity.subGridOptions.data = data.data;
                    row.entity.subGridOptions.gridHeight = 30 * row.entity.subGridOptions.data.length;
                    row.entity.subGridOptions.expandableRowHeight = 30 * row.entity.subGridOptions.data.length;
                    this.gridOptions.expandableRowHeight = 30 * row.entity.subGridOptions.data.length;
                })
                .catch((reason: any) => {
                    this.propagateApiError(reason);
                })
                .finally(() => {
                    this.loaderOff();
                });
        }
    });
};
和行模板:

    const defaultExpandableRowTemplate = '<div ui-grid="row.entity.subGridOptions"ui-grid-expandable style="border: 0px!important"></div> ';
constDefaultExpandableRowTemplate='';

我必须解决同样的问题。 下面是TypeScript中的代码:

protected doOnRegisterGridApiCore(gridApi: uiGrid.IGridApi) {
    this.gridApi = gridApi;
    gridApi.expandable.on.rowExpandedStateChanged(null, row => {
        if (row.isExpanded) {
            debugger;
            row.entity.subGridOptions = {
                expandableRowTemplate: defaultExpandableRowTemplate,
                expandableRowScope: row.entity,
                columnDefs: this.gridOptions.columnDefs,
                headerTemplate: '<div></div>',
                footerTemplate: '<div></div>',
                enableHorizontalScrollbar: 0,
                enableVerticalScrollbar: 0,
                onRegisterApi: (gridApi) => { this.doOnRegisterGridApi(gridApi); },
                enableExpandable: true,
                enableExpandableRowHeader: false,
                enableMinHeightCheck: false
            };
            this.treeGridFactory.get(row.entity)
                .then(data => {
                    debugger;
                    row.entity.subGridOptions.data = data.data;
                    row.entity.subGridOptions.gridHeight = 30 * row.entity.subGridOptions.data.length;
                    row.entity.subGridOptions.expandableRowHeight = 30 * row.entity.subGridOptions.data.length;
                    this.gridOptions.expandableRowHeight = 30 * row.entity.subGridOptions.data.length;
                })
                .catch((reason: any) => {
                    this.propagateApiError(reason);
                })
                .finally(() => {
                    this.loaderOff();
                });
        }
    });
};
和行模板:

    const defaultExpandableRowTemplate = '<div ui-grid="row.entity.subGridOptions"ui-grid-expandable style="border: 0px!important"></div> ';
constDefaultExpandableRowTemplate='';