Issues with AngularJS and UI-grid: the gridOptions are being overlooked by the grid

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>

Answer №1

To implement the changes in your HTML, make sure to include the following code:

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

By including the necessary options in addition to the data, you will ensure that all required settings are properly passed to the UI-Grid for correct functionality.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for inserting a hyperlink into a Chakra UI toast

Exploring the integration of Chakra UI within my Next.js project has led me to a curious question: Can Chakra UI toasts accommodate links and styled text? If so, what is the process for implementing these features? ...

Alert: Zone.js has identified that the ZoneAwarePromise '(window|global).Promise' has been replaced with polyfills. Kindly address this issue

Recently, I updated my Angular application from version 8 to 9. After updating the packages and successfully compiling the application, I encountered an error message in the Chrome browser console: Error: Zone.js has detected that ZoneAwarePromise `(wind ...

Enhancing Navigation on Bootstrap Pages with Next and Previous Buttons Linked to Specific IDs

Currently, I am working on integrating next/prev buttons and swipe functionality into a Bootstrap modal image gallery. The challenge I'm facing is that the thumbnails are presented in a grid format, causing issues when navigating through different col ...

Guide to executing a script within an iFrame on the parent webpage?

If I have a webpage named Page B with a function called "test()", and then another webpage named Page A that includes an iFrame pointing to Page B, how can I trigger the execution of Page B's "test()" function from Page A? ...

Sending an array containing a mix of data types from PHP to a JavaScript array

I am facing a problem with my asynchronous / getJSON implementation. I have an array loaded from a MySQL database in a PHP file called "loadblocks.php" and I have verified that the output is correct by echoing json_encode($content). The data is being print ...

Do the circular dependency warnings in Angular pose a significant issue?

Angular has long supported a showCircularDependencies build flag that identifies circular dependencies within classes. But do these warnings pose a real issue? Let's consider an example. import {MyOtherService} from './my-other-service.ts'; ...

Using React to map through a nested array within an object

In an attempt to extract the nested array "records", my current approach shows the array in the react console, but with an error. I will try to be brief while still providing necessary details. Upon encountering an error, there are 3 lines specifically po ...

Error in ReactJS: Attempting to access property 'preventDefault' of an undefined value

Looking to implement a simple onClick event/function in ReactJS. Upon clicking the button, I intend to execute a function named "onClick", but I encounter this error message in the console: app.js:62 Uncaught TypeError: Cannot read property 'prevent ...

Is there a limit to the amount of data that can be handled by AngularJS on the client-side

Is there a set of best practices or guidelines for determining the optimal amount of data for client-side processing (sorting/filtering) with AngularJS? I'm considering implementing a trigger in my code - such as performing server-side manipulation w ...

Numerous comparisons between ngIf and ngShow are made when dealing with intricate user interfaces and form structures

After searching, I couldn't find a satisfactory answer to my question about when to use ngShow versus ngIf. Alternative to ng-show/-hide or how to load only relevant section of DOM What is the difference between ng-if and ng-show/ng-hide When to fav ...

Tips for refreshing a GET request within a Vue.js application

I am receiving data from my Rails API backend and I would like to automatically refresh that GET request every 15 seconds. This way, if there are any changes on the backend (for example, if a POST request is made to another route), it will reload and retri ...

The slice() method in arrays provides a reference to the elements rather than copying

In my file, I am exporting an object in the following manner: export const LINECHART2_DATA = { series: [{ data: [], name: 'HR', }, { etc... }] } The way I import it is like this: import { LINECHART2_DAT ...

The feature for performing addition (+) calculations in AngularJS seems to be malfunctioning

While working with an angular controller, I attempted to calculate $scope values. For example: the code snippet below successfully multiplies values within brackets. However, when it comes to addition (+), it results in 400+200 = 400200 instead of 600. H ...

Is there a simple and efficient method to transition the loading of a regular website to AJAX for the entire site?

Is it feasible to easily and quickly change all links on a website to load the URL that the user clicked via AJAX, rather than refreshing the webpage? My website currently has standard links, but in order to create a mobile application for iPhone, I need ...

BS Modal was improperly invoked, leading to an illegal instantiation

Currently, I am attempting to trigger a bootstrap Modal in Angular by utilizing the component instead of its HTML attribute. However, I am encountering an error (specifically, illegal invocation). Here is the code snippet from the component: @ViewChild(&a ...

Establishing Accessor and Mutator Methods

The variables startStopA... and InitialValueA... that were originally in the component TableFields.vue need to be relocated to the store file index.js. However, upon moving them to the store, an error appears stating that setters are not set. I have extens ...

Configure markers on Google Maps

I've been attempting to integrate my markers into Google Maps, but I'm stuck on how to use the following: map.fitBounds(latlngbounds); Any ideas on how I can implement this easily? Below is the code I have so far: <script type="text/javas ...

What is the best way to create a moving line using EaselJS and TweenJS?

My objective is to animate a line from point A to point B using the Tween function. I am utilizing the EaselJS drawing library and TweenJS for animation. Can I achieve this by using the moveTo function to animate a straight line from point A to point B? ...

Tabbed horizontal slider

I am trying to combine two scripts in order to create a tab-based system with a scrollbar located at the bottom of the content. I have merged the following Ajax tabs: with this slider: However, when I open the slider's tab, I am unable to move the s ...

Obtain the last x elements

What is the most efficient way to extract a specific number of elements from the end? <div><span>1</span></div> <div><div>looks like 2</div></div> <div>three!!</div> For instance, how could I re ...