J'ai un ag-grid qui fonctionne dans le projet. Mais maintenant, lorsque j'ai porté la même chose à une autre page, j'ai obtenu une erreur. J'ai essayé d'éviter l'appel http entre les deux et j'ai essayé directement de définir les données ROW par le biais de
$scope.gridOptions.api.setRowData(RowDatas);
mais l'erreur est "TypeError : Cannot read property 'setRowData' of undefined".
Donc, en déboguant, j'ai réalisé que l'api est indéfinie. Voici mon code complet. S'il vous plaît, vérifiez ce que j'ai oublié.
<head>
<script src="js/angular_1_3_8.js"></script>
<script src="js/angular-filter.js"></script>
<script src="workbench/agGrid/dist/ag-grid.js?ignore=notused34"></script>
<script>
agGrid.initialiseAgGridWithAngular1(angular);
var app = angular.module("workbenchApp", ['angular.filter',"agGrid"]);
app.controller("workBenchCtrl", function ($scope, $http, $filter) {
var columnDefs = [
{headerName: "Name", field: "Name"},
{headerName: "Cr", field: "dc"},
{headerName: "Ac", field: "da"},
{headerName: "Mo", field: "dm"},
];
var RowDatas=[{"Name": "SUHDLOG.DAT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:51:22"},
{ "Name": "BOOTLOG.PRV", "dc": "1970-01-01 05:30:00", "da": "2005-04-01 00:00:00", "dm": "2005-04-01 15:13:30"},
{ "Name": "FRUNLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:52:56"},
{ "Name": "COMMAND.COM", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
{ "Name": "BOOTLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2005-04-02 00:00:00", "dm": "2005-04-02 14:38:00"},
{ "Name": "DETLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-28 00:00:00", "dm": "2002-12-28 09:56:02"},
{ "Name": "CONFIG.SYS", "dc": "1970-01-01 05:30:00", "da": "2005-06-16 00:00:00", "dm": "2003-07-03 18:39:50"},
{ "Name": "DBLSPACE.BIN", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
{ "Name": "MSDOS.SYS", "dc": "1970-01-01 05:30:00", "da": "2003-07-03 00:00:00", "dm": "2002-12-27 10:01:58"},
{ "Name": "DRVSPACE.BIN", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "1999-04-23 22:22:00"},
{ "Name": "MSDOS.---", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:46:28"},
{ "Name": "SETUPLOG.TXT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 10:04:12"},
{ "Name": "WSOCK32.DLL", "dc": "1970-01-01 05:30:00", "da": "2005-06-16 00:00:00", "dm": "2002-12-27 09:47:10"},
{ "Name": "CFGWIZ.DLL", "dc": "1970-01-01 05:30:00", "da": "2005-02-26 00:00:00", "dm": "2002-12-27 09:47:12"},
];
$scope.gridOptions = {
angularCompileHeaders: true,
columnDefs: columnDefs,
rowData:[{"Name": "SUHDLOG.DAT", "dc": "1970-01-01 05:30:00", "da": "2002-12-27 00:00:00", "dm": "2002-12-27 09:51:22"}]
};
/*
$http.get('FileList.json').success(function (response) {
$scope.TData = response;
DateArray=$scope.TData.Files;
$scope.gridOptions.api.setRowData(DateArray);
});
*/
$scope.gridOptions.api.setRowData(RowDatas);
});
</script>
</head>
<body>
<div ng-app="workbenchApp">
<div ng-controller="workBenchCtrl">
<div ag-grid="gridOptions" class="ag-blue" style="height: 500px;"></div>
</div>
</div>
</body>