The data is failing to display in ui-grid; an issue arises stating that b.forEach does not function correctly

Despite defining columns and groups, I encounter an issue while constructing the grid. What could be causing it?

 $scope.gridOptions = {
                enableFiltering: true,
                treeRowHeaderAlwaysVisible: false,
                columnDefs: [
                    { name: 'suplierName', grouping: { groupPriority: 0 }, sort: { priority: 0, direction: 'desc' }, width: '30%', cellTemplate: '<div><div ng-if="!col.grouping || col.grouping.groupPriority === undefined || col.grouping.groupPriority === null || ( row.groupHeader && col.grouping.groupPriority === row.treeLevel )" class="ui-grid-cell-contents" title="TOOLTIP">{{COL_FIELD CUSTOM_FILTERS}}</div></div>' },
                    { name: 'InvoiceNumber', width: '25%' },
                    { name: 'Description', width: '25%' },
                    { name: 'InvoiceDate', width: '40%', cellFilter: 'date', type: 'date' },
                    { name: 'CurrencyDate', width: '40%', cellFilter: 'date', type: 'date' },
                    { name: 'InvoiceTotal', width: '25%', cellFilter: 'number', type: 'number'},
                    { name: 'InvoiceNotPayed', width: '25%', cellFilter: 'number', type: 'number'},
                    { name: 'TotalPayment', width: '25%', cellFilter: 'number', type: 'number'}

                ],
                onRegisterApi: function( gridApi ) {
                    $scope.gridApi = gridApi;
                }
            };



            $scope.gridOptions = {
            };

            $http.get('http://11.141.111.111/server/api/reports/unpayedInvoicesReport/organization/a255f922-6a4b-11e4-a7ff-53ee038745a3/fromAccount/62386806-fb07-4821-a83b-eab0cc987778/toAccount/62386806-fb07-4821-a83b-eab0cc987778?dateTo=31%2F01%2F2015')
                .success(function(data)
                {

                    console.log(data)

                    for ( var i = 0; i < data.length; i++ ){
                        //var registeredDate = new Date( data[i].registered );
                        data[i].suplierName = data[i].suplierName;
                        data[i].InvoiceNumber = Number( data[i].InvoiceNumber .slice(1).replace(/,/,'') );
                        data[i].Description = data[i].Opis;
                        data[i].InvoiceDate = $filter('date')(new Date(data[i].InvoiceDate), 'dd/MM/yyyy')
                        data[i].CurrencyDate = $filter('date')(new Date(data[i].CurrencyDate), 'dd/MM/yyyy')
                        data[i].InvoiceTotal = Number( data[i].InvoiceTotal.slice(1).replace(/,/,'') );
                        data[i].InvoiceNotPayed = Number( data[i].InvoiceNotPayed.slice(1).replace(/,/,'') );
                        data[i].TotalPayment = Number( data[i].TotalPayment.slice(1).replace(/,/,'') );

                    }
                    $scope.gridOptions.data = data;

                });



            $scope.toggleRow = function( rowNum ){
                $scope.gridApi.treeBase.toggleRowTreeState($scope.gridApi.grid.renderContainers.body.visibleRowCache[0]);            };

            $scope.changeGrouping = function() {
                $scope.gridApi.grouping.clearGrouping();
                $scope.gridApi.grouping.groupColumn('age');
                $scope.gridApi.grouping.aggregateColumn('state', uiGridGroupingConstants.aggregation.COUNT);
            };

            $scope.getAggregates = function() {
                var aggregatesTree = [];
                var gender

                var recursiveExtract = function( treeChildren ) {
                    return treeChildren.map( function( node ) {
                        var newNode = {};
                        angular.forEach(node.row.entity, function( attributeCol ) {
                            if( typeof(attributeCol.groupVal) !== 'undefined' ) {
                                newNode.groupVal = attributeCol.groupVal;
                                newNode.aggVal = attributeCol.value;
                            }
                        });
                        newNode.otherAggregations = node.aggregations.map( function( aggregation ) {
                            return { colName: aggregation.col.name, value: aggregation.value, type: aggregation.type };
                        });
                        if( node.children ) {
                            newNode.children = recursiveExtract( node.children );
                        }
                        return newNode;
                    });
                }

                aggregatesTree = recursiveExtract( $scope.gridApi.grid.treeBase.tree );

                console.log(aggregatesTree);
            };
        }])

After receiving data from the server, a certain error occurred:

angular.js:11607 TypeError: b.forEach is not a function
    at p.modifyRows (ui-grid.min.js:7)
    at ui-grid.min.js:7
    at processQueue (angular.js:13189)
    at angular.js:13205
    at Scope.$eval (angular.js:14401)
    at Scope.$digest (angular.js:14217)
    at Scope.$apply (angular.js:14506)
    at done (angular.js:9659)
    at completeRequest (angular.js:9849)
    at XMLHttpRequest.requestLoaded (angular.js:9790)

As a newbie to Angular, any suggestions or tips would be greatly appreciated :) This is my first attempt at implementing UI-grid, and its features are essential for my project. Thank you!

Answer №1

Please delete line 24 and 25 from the provided code snippet.

$scope.gridOptions = {
};

It is important to note that defining $scope.gridOptions again in this manner will nullify any previous settings.

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

Executing JavaScript code within an iframe using the AMP framework

Currently, I am utilizing Next.js with AMP functionality enabled. For more information, check out: https://nextjs.org/blog/next-8-1 However, I have encountered an issue where any JavaScript included in my React code is only executed on the server side and ...

What is the best way to navigate through a series of images using left and right arrows in a React

I need help implementing a feature where I can slide horizontally through a collection grid of 10 movie items per row, similar to Netflix grids. Is there an easy way to achieve this with arrows on the right and left ends? <div className="collection-p ...

Problem with adding dates to an array using the push method: unexpected values being added

Looking to retrieve dates within a specified range d = 'Tue Oct 2 00:00:00 UTC+0900 2018'; date2 = 'Fri Oct 5 00:00:00 UTC+0900 2018'; var arrTemp = new Array(); //var dispalyHTML = ''; while(d <= date2){ //dis ...

JavaScript will not modify the content of the page

Initially, everything was working fine with this code when I was using a JavaScript window prompt to input the length. However, I decided to switch it up and use an if statement along with a dropdown window in the HTML, and now it doesn't seem to be w ...

Display a Button exclusively at the bottom row of a Table using just Javascript

I am currently working on a 4-column table with a "+" button in the last column. This button's purpose is to add an additional column when clicked. However, the button is appearing in all rows of the table, and I would like it to be displayed only in ...

There was a problem with the ES Module requirement while trying to use retry-axios, resulting in the following error: [

const rax = require('retry-axios'); Error [ERR_REQUIRE_ESM]: encountered an issue with require() for ES Module While attempting to set up a retry mechanism using retry-axios, I ran into the Error [ERR_REQUIRE_ESM]: require() of ES Module error. ...

Transforming the setting into redux using setTimeout

I am currently working with the following context: interface AlertContextProps { show: (message: string, duration: number) => void; } export const AlertContext = createContext<AlertContextProps>({ show: (message: string, duration: number) =&g ...

Enhancing User Interface with AngularJS and NodeJS: Dynamically updating and animating the

I am currently coding in angularjs/nodejs To pull data from my database, I have utilized the powerful $http service. And for displaying this data on the view, I have incorporated the ngRepeat directive. However, I am facing a challenge. Whenever I add ...

Simulating the Fourier Series

I've created a unique drawing app that transforms sketches into Fourier series, but it's exhibiting an unusual behavior where it spirals inwards unexpectedly. Strangely, all the constants within the series are of similar size, which I suspect is ...

Apply a unique color to the highest value within each column using AngularJS ng-repeat

I just started learning Angularjs, and I'm not sure how to achieve this. I want to highlight the member with the highest Score, Missed, and Field Goal percentage by adding color. Is there a way to do this? https://i.sstatic.net/9KF5D.png Is it poss ...

Best practices for ensuring text remains in the correct position on all screen sizes when overlaying a large image

In the introductory page, I have a large image that spans more than 4000px in width to accommodate different resolutions. The image is set with the following CSS: #source-image { width: 100%; position: absolute; top: 0; left: 0; } On top ...

Conceal the visibility of the popover in Onsen UI

Before anyone criticizes me for not trying existing solutions, I have attempted them and unfortunately, they did not work for me. I followed the suggestions in similar questions linked below without success: How to hide popover in onsen ui I am puzzled as ...

Why am I getting multiple results when using the findOne method in my Mongoose query?

Why is my route not returning only one matched thing when using findOne with the thing object id as a parameter? I have attempted to use findOne with the id as a parameter. Schema of the Thing: const mongoose = require("mongoose"); const thingSchema = m ...

definition of a function with another function

I'm curious about whether it's considered a good practice in JavaScript to define a function within another function. Take a look at this code snippet: module.exports = function() { function foo() { // do something } ... foo() .. ...

Dealing with issues related to AngularJS auto-tab functionality

I implemented the code below to enable "auto tab" functionality with AngularJS, which automatically shifts focus to the "Title" textbox after the maximum length is reached in the "Name" textbox: var app = angular.module('plunker', []); app.dire ...

Ways to incorporate a while loop into a randomizing function

I've been diving into JavaScript and managed to create a website that displays random gifs when clicked from an array. Now, my goal is to implement a while loop to prevent duplicate images from being shown consecutively. However, I seem to be facing ...

Ensure that the PWA continues to operate in the background

I have developed a progressive web app using Angular 9. The purpose of the application is for trading, so the data changes constantly. Users can create statements and when these statements come true, the application sends notifications. I have also install ...

Save the current state of the collapsible navigation menu

I developed a website for a friend, but I'm encountering an issue with my js/css vertical and collapsible menu. Every time I click a link, the new page loads and the entire menu collapses again. I've tried to figure out a way to "store" the infor ...

Blog entries alternating between a pair of distinct hues

I want to create a design where each post container has a different color from the one next to it. Essentially, I would like the containers to alternate between two distinct colors. The left side shows how it currently appears, while the right side depict ...

JavaScript is failing to match the float and string values

Trying out this code snippet: if(total === balance) { alert("test passed"); } else { alert("test failed"); } In this scenario, total = 10; and balance = 10.00;, yet the output is "test failed". ...