Ng-Grid error: Trying to access property 'on' of a null value

Currently, I am in the process of creating an angular.js directive that involves a JQuery dialog box containing a grid component.

Directive Template:

<div class="datasetsGrid" ng-grid="gridOptions"></div>

The Issue

Whenever I click on the "View Grid" button, the directive is compiled and displayed. However, upon closing and reopening the dialog, I encounter the following error:

TypeError: Cannot read property 'on' of null
    at self.assignEvents (https://127.0.0.1/Scripts/Libraries/Angular/ng-grid-2.0.11.js:1003:29)
    at Object.fn (https://127.0.0.1/Scripts/Libraries/Angular/ng-grid-2.0.11.js:3260:52)
    at Scope.$digest (https://127.0.0.1/Scripts/Libraries/Angular/angular.js:12251:29)
    at Scope.$apply (https://127.0.0.1/Scripts/Libraries/Angular/angular.js:12516:24)
    at done (https://127.0.0.1/Scripts/Libraries/Angular/angular.js:8204:45)
    at completeRequest (https://127.0.0.1/Scripts/Libraries/Angular/angular.js:8412:7)
    at XMLHttpRequest.xhr.onreadystatechange (https://127.0.0.1/Scripts/Libraries/Angular/angular.js:8351:11) 

This issue stems from the code section within ng-grid-2.0.11.debug.js:

        grid.$groupPanel.on('mousedown', self.onGroupMouseDown).on('dragover', self.dragOver).on('drop', self.onGroupDrop);
        grid.$topPanel.on('mousedown', '.ngHeaderScroller', self.onHeaderMouseDown).on('dragover', '.ngHeaderScroller', self.dragOver);

        grid.$groupPanel.on('$destroy', function() {
            if (grid.$groupPanel){
                grid.$groupPanel.off('mousedown');
            }

            grid.$groupPanel = null;
        });

        if (grid.config.enableColumnReordering) {
            grid.$topPanel.on('drop', '.ngHeaderScroller', self.onHeaderDrop);
        }

        grid.$topPanel.on('$destroy', function() {
            if (grid.$topPanel){
                grid.$topPanel.off('mousedown');
            }

            if (grid.config.enableColumnReordering && grid.$topPanel) {
                grid.$topPanel.off('drop');
            }

            grid.$topPanel = null;
        });

This snippet can be located around line 997 in the ng-grid-2.0.11.debug.js file.

It appears that in ng-grid-2.0.11.debug.js line 997, the code attempts to add events to a null object grid.$groupPanel. This object becomes null when the dialog is closed and then reopened, leading to this error message in the developer tools.

Notably, the group panel (which remains enabled) still functions correctly.

I do have a workaround for this problem by modifying the ng-grid-2.0.11.debug.js file, but I prefer to avoid this as I want to maintain it up-to-date. It seems like there might be something I am doing incorrectly in my implementation.

Has anyone else faced this problem before? If so, how did you manage to resolve it?

Answer №1

Resolved in ng-grid-2.0.14.debug.js

Get the updated edition from Here

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

Switching Div Elements Created by PHP

Utilizing MySQL, I am fetching data to dynamically generate nested div tags in a hierarchical structure. This structure consists of div tags within div tags within div tags, all uniquely identified through PHP-generated ids: <div class="holder"> ...

Do we really need TypeScript project references when transpiling with Babel in an Electron project using Webpack?

Currently, I am in the process of setting up my project configuration and have not encountered any errors so far. However, based on my understanding of the Typescript documentation... It appears that Project references are not essential when using babel-l ...

The error message that keeps popping up is saying that it cannot access the property "username" as it is undefined

signup.js const SignupForm = () => { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const handleSignup = () => { fetch("/signup", { method: "post", header ...

Tips for positioning a chat box at the bottom of a v-card's visible area

My goal is to create a chat app using Vuejs 3 and Vuetify 3, but I'm encountering an issue aligning the chatbox with the v-card component. Instead of being positioned at the bottom of the v-card, the chatbox (green) appears at the bottom of the page. ...

The JSP AJAX response comes back empty

I am encountering an issue where I am using JQuery Ajax to call a REST API in JSP, but it keeps returning null no matter how I try. Strangely enough, the same code works when used in HTML. I have been searching online for a solution but haven't found ...

Revoke the prior invocation of the Google Maps geocoding function

While working on implementing an autocomplete with JavaScript and the Google Maps geocode method (using the keyup event on input), I have encountered a problem where I sometimes receive the results of the previous search instead of the current one. I am l ...

"Triggering an AJAX POST request with a click event, unexpectedly receiving a GET response for

Hello there! I am currently attempting to send an AJAX POST request when a button is clicked. Below is the form and button that I am referring to: <form class="form-horizontal" > <fieldset> <!-- Form Name --> <legend> ...

tslint issues detected within a line of code in a function

I am a novice when it comes to tslint and typescript. Attempting to resolve the error: Unnecessary local variable - stackThird. Can someone guide me on how to rectify this issue? Despite research, I have not been successful in finding a solution. The err ...

Executing the callback function

I am facing a situation where I have a Modelmenu nested within the parent component. It is responsible for opening a modal window upon click. Additionally, there is a child component in the same parent component that also needs to trigger the opening of a ...

Unable to select an option in AngularJs using ng-repeat

How can I preselect an option in a select element rendered by ng-repeat? <body ng-app ng-controller="AppCtrl"> <div>Chosen leverage: {{openAccount.leverage}}</div> <select class="form-control" name="leverage" ng-model="openAcc ...

By utilizing the HTML element ID to retrieve the input value, it is possible that the object in Typescript may be null

When coding a login feature with next.js, I encountered an issue: import type { NextPage } from 'next' import Head from 'next/head' import styles from '../styles/Home.module.css' import Router from 'nex ...

Error: Property 'html' is undefined - AJAX response must be displayed only in a specific div

I encountered an issue: Uncaught TypeError: Cannot read property 'html' of undefined I am working on implementing a voting system for each video on my webpage from a database. I have successfully integrated it using AJAX, but the problem is ...

Failure to post in jQuery and PHP

I'm facing a slightly complex issue involving jQuery and PHP on my index.php file. The page makes a call to a javascript function called getCalls(). function getCalls() { $('#transportDiv').load('getCalls.php'); } The getCall ...

Create static HTML files using an Express server

Recently, I developed a nodejs web project using express-js and ejs. However, upon further reflection, it occurred to me that hosting it as static html files on Netlify might be more cost-effective than running it as a nodejs app on Heroku. Since the data ...

What is the most popular method for namespacing AngularJS modules?

I am new to AngularJS and currently exploring different ways to namespace modules in my application. One challenge I face is the need to integrate my Angular app into a designated placeholder div within a third-party website (which may also use Angular), ...

Transform a <td> into a table-row (<tr>) nested within a parent <tr> inside an umbrella structure

Similar questions have been asked in the past, but I still haven't found a solution to my specific inquiry. Here it is: I have a table that needs to be sortable using a JavaScript plugin like ListJS. The key requirement is that I must have only one & ...

When I try to hover my mouse over the element for the first time, the style.cursor of 'hand' is not functioning as expected

Just delving into the world of programming, I recently attempted to change the cursor style to hand during the onmouseover event. Oddly enough, upon the initial page load, the border style changed as intended but the cursor style remained unaffected. It wa ...

Difficulties with integrating tooltips into SVGs

Being a minimalist, I am facing restrictions while working on a website. I desire interactive tooltips to appear when users hover over specific sections of my SVG. However, I also want to incorporate this interactivity within the SVG itself. The challenge ...

Django template experiences issue with AJAX functionality when attempting to open a new window through right-click action

I have successfully created a link using AJAX with the following HTML code: <a id="post_click" href="{{ post.online_url}}" rel="nofollow"> <button class="w-100 " type="button" name="button& ...

Exploring Vue Component Features through Conditional Display

I am working with a vue component called <PlanView/>. In my code, I am rendering this component conditionally: <div v-if="show_plan" id="mainplan"> <PlanView/> </div> <div class="icon" v-else> ...