我是 agGrid 的新手,如果您发现一些愚蠢的东西,请原谅我。所以在此之前,我在 angularjs 上使用 Kendo Grid,但我们想切换到其他一些网格,所以我们现在正在尝试 agGrid。
下面是 aggrid 的示例,它运行良好并且一切正常。但是,当我将我的网格选项移动到一个将在单击按钮时调用的函数中时,我收到了警告 - 未找到 ag-Grid 的网格选项。请确保属性 ag-grid 指向范围内的有效对象。
我无法理解问题出在哪里,因为在此函数中,kendo 网格选项工作正常并且 kendo 网格正在填充,但我不确定我在 agGrid 上做错了什么。
请帮助我。
function abc($rootScope,$scope, $state, $stateParams, $timeout, Upload, baseURL, $cookieStore, $log, errorCheckFactory) {
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}
];
$scope.gridOptions2 = {
columnDefs: columnDefs,
rowData: rowData,
enableFilter: true,
enableColResize: true,
enableSorting: true,
groupHeaders: true,
rowHeight: 22,
//onModelUpdated: onModelUpdated,
suppressRowClickSelection: true
};
最佳答案
如果网格没有找到您的 gridOptions,那肯定意味着您的 html 模板中有拼写错误
检查它必须具有的 hml 模板
ag-grid="gridOptions2"
注意:如果您使用带有 controllerAs 方式的 Controller ,则必须在 this 而不是 $scope 上绑定(bind)变量。
如果不是这个,请添加您的 html 和您的路线/状态/导航的任何定义。
关于javascript - ag-grid 没有在函数内部填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35745645/