我正在尝试动态添加列ui-grid并分配数据.第一次,电网工作正常.但是,当我尝试动态更改列和数据时,它无法正常工作.
$scope.myfunc = function() {
alert("Rebinding the data");
$scope.gridOptions = {};
$scope.gridOptions.columnDefs.push({
name: 'firstName'
});
$scope.gridOptions.columnDefs.push({
name: 'lastName'
});
$scope.gridOptions.columnDefs.push({
name: 'company'
});
$scope.gridOptions.columnDefs.push({
name: 'employed'
});
alert("added new columns");
$scope.gridOptions.data = data1;
$scope.gridApi.grid.refresh();
};
Run Code Online (Sandbox Code Playgroud)
请检查一下plunkr
任何人都可以调查这个问题并建议我如何做到这一点?