I am trying to add columns dynamically to the ui-grid and also assigning the data. First time, the grid is working good. But, when i try to change the columns and data dynamically, it is not working as expected.
$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();
};
please check the plunkr
Can anybody look into this issue and suggest me how to do this?