Utilizing UI-GRID to showcase JSON information

I am currently in the process of fetching data from the server.

[
  {
    id:1, 
    name:demo,
    request: {
      id: 1,
      localCompany: {
        id: 1
      }
   }
}]

[{ }, { }] This is how my JSON object appears to be structured.

After calling the $http service and assigning it to gridOptions: {data: this.data}, I encounter an error message in the console: TypeError: newRawData.forEach is not a function.

 data: ng.IPromise<any[]> = this.programService.getRequestsForProgram(this.model.id).then((data: any) => {
        console.log(data);
        return data;
    });

gridOptions: {} = {
        data: this.data ,
        paginationPageSize: 5
        //columnDefs: this.programCountryService.getHeaders()
    };

This is my current code implementation.

Any suggestions on how to resolve this error? Is there a way for the grid to only display localCompany.Id instead of name:demo?

Answer №1

Attempt to store the information in $scope.data

Assign $scope.data = getData from the server

Afterwards,

gridOptions: {} = { data: $scope.data , paginationPageSize: 5 //columnDefs: this.programCountryService.getHeaders() };

Answer №2

Insert the information labeled as data into the variable $scope, then assign it to gridOptions.data = $scope.data.

To display data only for localCompany.id, you must create a definition for columnDefs for the field request with a customized template like this:

'<div class="ui-grid-cell-contents">{{ COL_FIELD.id }}</div>'

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

There was a problem encountered while trying to import Json data

I'm having trouble importing my JSON file into R. I've installed the necessary packages and here's what I attempted: library(rjson) JsonData <- fromJson(file= "<filename.json>") I also tried using the file path and the jsonlite pa ...

What is the best way to handle JSONp response parsing using JavaScript?

I'm relatively new to working with Javascript and I am currently attempting to retrieve data from an External API located on a different website. My goal is to extract the information, parse it, and then display specific parts of it within my HTML pag ...

Display a singular value using ng-show when identical data is received for the specified condition

This section will display the result based on the selected language. For example, if "English" is selected in myAngApp1.value, it will display the content in English. However, since all four languages have an English value in SharePoint list, it displays t ...

In an attempt to transform a List<T> into a JsonString for storage in sharedPreferences, there arises the challenge of dealing with a data structure that includes both a Contact object and a boolean value within &

Struggling with saving a list to sharedpreferences by converting it to JsonString. Facing the issue of 'encodable object failed: Instance of 'CustonContact''. Looking for assistance. class CustomContact extends Contact{ Contac ...

After the rendering process, the React Component member goes back to a state of

One issue I encountered is related to a component that utilizes a separate client for making HTTP requests. Specifically, when trying to use the client within a click event handler, the call to this.client.getChannel() fails due to this.client being undefi ...

Ways to access the new value of a cell in a Material UI Datagrid through the use of GridCellParams

When trying to access the newly modified value in a cell using the GridCellParams interface, I am faced with the issue that the 'value' property only provides me with the previous value of the cell. This asynchronous behavior is not ideal for my ...

Dealing with directive minification problems in AngularJS

Another issue regarding minification has arisen. This time, it involves the $scope service being passed to the controller of a directive. Take a look at the code snippet below: angular.module('person.directives'). directive("person", ['$dia ...

Traverse a deeply nested JSON array within an Angular controller to extract distinct values

I am currently facing a challenge where I need to iterate through a nested JSON array structured like this: [ { "title": "EPAM", "technologies": [ "PHP", ".net", "Java", "Mobile", "Objective-C", "P ...

Tips for utilizing ui-sref in a complex Angular UI router configuration

After spending hours researching and implementing different techniques, I am still unable to solve the issue. My application consists of three main navigations: home, sports, and country. <head> <script src="js/angular-ui-router.min.js"></s ...

AngularJS2 brings a powerful and seamless implementation of indexedDB for efficient

I'm on the hunt for an indexeddb implementation that works seamlessly with Angularjs2. While I stumbled upon this api at https://github.com/gilf/angular2-indexeddb, it appears to be lacking in active development and may not be ready for production use ...

Changing the font family for a single element in Next.js

One unique aspect of my project is its global font, however there is one element that randomly pulls font families from a hosted URL. For example: https://*****.com/file/fonts/Parnian.ttf My page operates as a client-side rendered application (CSR). So, ...

Obtaining an image from encoded JSON information

This inquiry pertains to Visual Basic .NET 2010 How do I extract the image from this encoded JSON string? What type of encoding is being used here? I'm attempting to capture a screenshot of a website using the Google PageSpeed API. "screenshot": { ...

Utilizing Grunt to streamline a personalized project

I have set up Grunt as my "JS Task Runner". Node.js is installed in the directory "C:/Program Files". NPM has been installed in C:/users/Peterson/appdata/roaming/npm. Inside the npm folder, I have Grunt, Bower, and Grunt-cli. I am working on a pro ...

What is the reason behind the error Generic indexed type in Typescript?

Here is a scenario where I have a specific generic type: type MapToFunctions<T> = { [K in keyof T]?: (x: T[K]) => void; }; It functions correctly in this instance: type T1 = { a: string }; const fnmap1: MapToFunctions<T1> = { a: (x: st ...

JavaScript library called "Error: JSON input ended unexpectedly"

I am currently operating a server using node.js and Express v4.0 Additionally, I am utilizing the request library. However, when receiving a response from the server, I encounter an Uncaught SyntaxError: Unexpected end of JSON input. The response I receiv ...

Utilizing AngularJs for searching strings in a function

I'm currently working on implementing a search function using angularjs. However, I have encountered an issue where the function returns results based on my search query but when I delete the search query, it displays all objects in the set. Here&apos ...

Can you explain the significance of the output "Object[...]" displayed in Firebug?

Currently, I am logging an object within an AngularJS directive. Specifically, I am focusing on the parameters of the link() function of the directive. Here is the code snippet: link: function(scope, element, attrs) { console.log(attrs) } Upon checking ...

Having trouble passing $scope, $route, or $http in your AngularJS factory functions?

Why does my factory keep throwing an error when the $scope, $route, $http are present? app.factory("factoryContacts",function($scope,$route,$http){ return { getContacts: function(){ return $http({ me ...

Is there a way to merge two typed Joi schemas together?

I have two different interfaces, where the second one is an extension of the first: interface Core { id: string; } interface User extends Core { firstName: string; } To ensure validation, I utilize Joi schemas. For the Core interface, it's easy ...

Convert JSON data into CSV format through filtering process

Is there a way to extract specific key-value pairs from a JSON file and then save the remaining data as a CSV file? For example, if I want to exclude the headerName key and only include URL, Domain, Pages in the CSV: [{"URL": "http://help.abc.com/", "hea ...