Having trouble with ui-grid disabling grid menu and renaming columns? Check out this plnkr I made: https://plnkr.co/edit/EGhvBGOJCKPzfupjCROx?p=preview
In the script.js, I want my columns to be named 'banana', 'chrom', and 'position':
var app = angular.module('myApp', ['ui.grid']);
app.service('provide', ['$http', function($http) {
return {
getAllVariants: function () {
return $http.get('./varAjax.php');
}
};
}]);
app.controller('MainCtrl', ['$scope', 'provide', 'uiGridConstants', function($scope, provide, uiGridConstants) {
provide.getAllVariants().success(function(data) {
$scope.gridOptions.data = data;
$scope.myData = data;
console.log($scope.gridOptions);
console.log($scope.myData);
});
$scope.gridOptions = {
data: 'myData',
enableGridMenu: false,
showGroupPanel: true,
enableColumnResizing: true,
enableFiltering: true,
showGridFooter: true,
showColumnFooter: true,
columnDefs: [
{ name: 'id', displayName: 'banana', width: 30 },
{ name: 'chr', displayName: 'chrom', width: 30},
{ name: 'pos_start', displayName: 'position', width: 50}
]
};
}]);
Data looks like this:
[
{
"id":"1","chr":"chr1","pos_start":"11169789"
},
{
"id":"2","chr":"chr1","pos_start":"11172923"
}
]
Here's how I call my grid:
<body>
<h1>Variants</h1>
<div ng-app="myApp" ng-controller="MainCtrl">
<div id="grid1" ui-grid="{ data: myData }" class="myGrid"></div>
</div>
</body>