1

I'm having issues with ui-grid to disable gridMenu and to rename my columns. I've made a plnkr so you can see: https://plnkr.co/edit/EGhvBGOJCKPzfupjCROx?p=preview

As you can see in script.js, I'd like 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 is looking like that:

[
 {
 "id":"1","chr":"chr1","pos_start":"11169789"
 },
 {
 "id":"2","chr":"chr1","pos_start":"11172923"
 }
]

And here is 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>

1 Answer 1

3

Change your HTML to

<body>
    <h1>Variants</h1>
    <div ng-app="myApp" ng-controller="MainCtrl">
      <div id="grid1" ui-grid="gridOptions" class="myGrid"></div>
    </div>
  </body>

At the moment you are only passing the data to the UI-Grid and not the options, this will pass the options (such as the columndefs) and the data.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, it seems only logical now that you say it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.