0
votes

I am trying to display data using ag-grid in my ASP.NET Web forms application but, I am getting the following error:

require.js:143 Uncaught Error: Module name "dist/lib/clientExports" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded

TypeScript file:

require(['node_modules/ag-grid/main', ], function (agGridObj) {
    document.addEventListener("DOMContentLoaded", function () {
        var eGridDiv = document.getElementById('#AllProjectBuildInfoGrid');
        //new ag.grid.Grid(eGridDiv, gridOptions);
        new agGridObj.Grid(eGridDiv, gridOptions);
    });
});
var columnDefs = [
    { headerName: "Make", field: "make" },
    { headerName: "Model", field: "model" },
    { headerName: "Price", field: "price" }
];

var rowData = [
    { make: "Toyota", model: "Celica", price: 35000 },
    { make: "Ford", model: "Mondeo", price: 32000 },
    { make: "Porsche", model: "Boxter", price: 72000 }
];

var gridOptions = {
    columnDefs: columnDefs,
    rowData: rowData
};

earlier, I used NPM to download the ag-grid into my project. What am I doing wrong? How do I reference ag-grid in my typescript file? Any suggestion is appreciated.

1

1 Answers

0
votes

Cross reference how you are packing with the below link

https://www.ag-grid.com/understanding-packaging-for-javascript-typescript-commonjs-and-everything-else/

Not sure how you reference external JS libs in for non angular TS projects. Have you considered as explained in the below thread.

https://github.com/ceolter/ag-grid/issues/717