Ich verwende ein erweiterbares Benutzeroberflächenraster.
Meine Daten werden in einem Raster angezeigt, das beim Klicken erweitert wird, und das Raster wird alle 5 Sekunden aktualisiert.
Wenn ich eine Zeile expandiere, wird sie alle 5 Sekunden reduziert, wenn das Raster aktualisiert wird.
Wie kann ich die Zeilenerweiterung beibehalten, wenn das Raster aktualisiert wird?
Code
$scope.fillProductList = function () {
$http({
method: "GET",
url: getJobs,
data: {}
}).success(function (result) {
$scope.showSubListGrid = false;
$scope.myData = "";
var gridDataWithDownload = result;
//grid data
$scope.myData = gridDataWithDownload;
$scope.gridOptionsCategory.data = gridDataWithDownload;
// $scope.refresh = false;
timer = $timeout(function () {
$scope.fillProductList();
}, timeOutStamp);
}).error(function (result) {
timer = $timeout(function () {
$scope.fillProductList();
}, timeOutStamp);
});
};
$scope.gridOptionsCategory = {
useExternalPagination: true,
expandableRowHeight: 300,
enableSorting: true,
data: $scope.myData,
enableColumnResizing: true,
enableGridMenu: false,
expandableRowTemplate: "griddata.html",
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
// gridApi.expandable.toggleRowExpansion($scope.gridApi.grid.row[0].entity);
gridApi.expandable.on.rowExpandedStateChanged($scope, function (row) {
$scope.gridApi.grid.modifyRows($scope.gridOptionsCategory.data);
$scope.gridApi.selection.selectRow($scope.gridOptionsCategory
.data[0]);
//$scope.gridOptionsCategory.expandableRowHeight = 500;
//$timeout.cancel(timer);
if (row.isExpanded) {
row.entity.components = JSON.parse(row.entity.components)
this.scope.gridOptionsCategory.expandableRowScope = row.entity;
// $scope.GridOptions.expandableRowScope = row.entity.components;
}
if (!row.isExpanded) {
timer = $timeout(function () {
$scope.fillProductList();
}, timeOutStamp);
}
});
},
enableHorizontalScrollbar: 0,
//enableVerticalScrollbar:0,
//useExternalSorting: true,
columnDefs: [{
field: "filtertoggle",
displayName: "",
visible: true,
headerCellTemplate: "" +
"<button id="toggleFiltering" style= "padding:3px 7px;" ng-click="grid.appScope.toggleFiltering()" class="btn btn-warning glyphicon glyphicon-filter">" +
"</button>"
},
{
name: "Job Name",
field: "name",
width: "20%",
enableCellEdit: false,
enableHiding: true,
enableGrouping: false,
// enableFiltering: true,
filter: {
term: $scope.filterOptions.filterText
}
},
{
name: "Profile",
field: "profile",
width: "15%",
enableCellEdit: false,
enableHiding: true,
enableGrouping: false
}, {
name: "Progress",
field: "progress",
enableSorting: true,
width: "18%",
enableCellEdit: false,
enableHiding: true,
enableGrouping: false,
// enableFiltering: true,
cellTemplate: statusTemplate
}
]
};
Antworten:
0 für die Antwort № 1gridApi.core.on.rowsRendered(scope,() => {
if (!gridApi.grid.expandable.expandedAll && !initialized)
{ gridApi.expandable.expandAllRows();
initialized = true;
}
});
Können Sie mit diesem Code überprüfen? Sie könnten eine Idee bekommen.