Javascript 将子栅格添加到角度ui栅格子栅格
我有一个工作的有角度的ui网格,带有用于扩展网格的html模板。 在此模板中还有另一个ui网格。 如何使子网格也可扩展? 第一个可扩展的网格工作得很好,第二个(subsub)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',
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='';