I am wondering why my JSON appears in Kendo UI as Datasource.options.data but not Datasource.data

I'm new to Kendo and struggling to display my JSON data in the Kendo Grid. When I try to access my $scope.actionData using a regular HTML table, it displays on the page.

My ultimate goal is to achieve something similar to this.

The column headers are visible on the page, but there is no data underneath them.

Although I can see the expected data in Chrome Kendo UI Inspector under DataSource -> Options -> Data Array, I am unable to get it to display on the page or populate the DataSource -> Data array. I have tried following examples on the angular-kendo page with no success. Adding different elements/tags below the div in the HTML hasn't helped either.

Please let me know if you need any additional information. Any help in getting this to populate would be greatly appreciated. Thank you in advance!

HTML:

<div kendo-grid k-data-source="gridOptions"></div>

Controller:

var actionHistoryControllers = angular.module('actionHistoryControllers', ['kendo.directives'])
        .controller('ActionHistoryCtrl', ['$scope', '$routeParams', 'ActionHistory',
             function ($scope, $routeParams, ActionHistory) {
                 $scope.actionData = ActionHistory.query({ appid: $routeParams.appid },
                       function (data) {
                           $scope.error = false;
                           $scope.errorMsg = "";
                       },
                       function (data) {
                           $scope.error = true;
                           $scope.errorMsg = "<strong>Unable to load!</strong> Please reload the page.";
                       });

                 $scope.gridOptions = {
                     data: $scope.actionData,
                     columns: [
                         {field: "UserID", title: "User ID"},
                         {field: "ActionText", title: "Action Text"}]
                 }
              }])

Chrome Kendo UI Inspector:

Data source
   options: Object{9} 
   data: Array[3] 
      0: Object{17} 
        ActionHistoryID: 315911
        ActionText: "System"
        ...

Answer №1

Kindly update the code snippet below:

$scope.gridOptions = {
    data: $scope.actionData,
    columns: [
        {field: "UserID", title: "User ID"},
        {field: "ActionText", title: "Action Text"}]
}

to the revised version shown here:

$scope.gridOptions = {
    dataSource: {
        transport: {
            read: function (o) {                        
                o.success($scope.actionData);
            }
        },
        columns: [
            {field: "UserID", title: "User ID"},
            {field: "ActionText", title: "Action Text"}
        ]
    }
}

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

Mapping an array of strings to model field values in EXTJS

I currently work with EXT JS 4.1.1. Upon receiving a JSON response structured as follows: { values: ["A","B","C"] } I proceed to define a model in the following manner: Ext4.define('model', { extends: 'Ext4.data.model', fiel ...

Traversing JSON data structures regardless of missing keys

Here is a JSON containing some data: { "results":[ { "name":"Sydney Showboats", "photos":[ { "photo_reference":"Pic062" } ] }, ...

Unable to convert the text string into my desired object

The JSON string I received has been validated by jsonlint. A decodedCookie string is created using URLDecoder to decode the value of myCookie in UTF-8 format, and then Gson is used to parse it. Here is what the string looks like: { "urlAW": "http://w ...

The search bar in Laravel is encountering an Uncaught ReferenceError with AJAX

I'm attempting to create a real-time search bar for my products list, but I keep encountering an error in my console Uncaught ReferenceError: data is not defined at HTMLInputElement.<anonymous> (produits:243) at HTMLDocument.dispatch (jquery-2.2 ...

Exploring categories with AngularJS filtering

I dived into AngularJS today and embarked on creating a straightforward app featuring categories with items. The app showcases categories in a sidebar (aside.navigation) and displays all the items in the main view. My initial idea was to load all the item ...

"Highcharts error code 13: Troubleshooting inconsistent x-axis data in JSON

After spending 10 hours attempting to display data from a SQL database using highgraph, I've managed to produce a JSON file with my data. However, I'm facing difficulties in integrating this data into highcharts. I encountered an issue where Moz ...

Different methods to avoid using $scope.$watch in a directive when dealing with an undefined variable

As I work on my angularjs application, I find myself utilizing directives for reusable UI elements across different pages. However, I encounter a challenge when a directive depends on a value from a promise. In such cases, I have to employ $scope.$watch al ...

Creating an AngularJS factory that integrates with a Parse.com database

Hey there, I've been diving into AngularJS factories to manage data outside of controllers but I'm hitting a roadblock. I could really use some guidance, advice, or direction on this issue. Here's what I have so far, but I'm struggling ...

Mapping JSON data from an array with multiple properties

Here is a JSON object that I have: obj = { "api": "1.0.0", "info": { "title": "Events", "version": "v1", "description": "Set of events" }, "topics": { "cust.created.v1": { "subscribe": { ...

The Wikipedia API is unable to be loaded using the XMLHttpRequest

I have encountered this error before on this platform, and although I managed to fix it, I am seeking a more in-depth explanation of the solution. For a project where I am learning, I decided to create a Wikipedia Viewer application. The first step was to ...

When the JSON array is converted into a string, it appears as undefined

Below is a snippet of my service.spec.ts file: service.spec.ts it('should mock the http requests', inject([Service, MockBackend], (service, mockBackend) => { let result:any; mockBackend.connections.subscribe((connection) => { ...

Dealing with Memory Leaks in AngularJS and Jquery

My web application has been created with a combination of jQuery and Angularjs. I am currently on the lookout for patterns that could lead to memory leaks in Angularjs. I have used Chrome profiler as a tool to find memory leaks, but unfortunately haven&a ...

transferring a parameter in PHP

I am just starting out with PHP (with some experience in Java) However, I'm struggling to pass a variable as an argument. Here's my code snippet where I define the URL in a variable called "url" and try to use it to make an API call. The issue ...

How to style the first dropdown value in AngularJS to appear bold?

Is there a way to style only the first value in a dropdown list as bold without using jQuery? Here is the code for the dropdown: <div class="col-xs-3"> <select-box id="ad-version-select" options="curItem.stats.version" model="state.version" i ...

Dynamic Selection of JSON Key-Value Pairs in React Framework

My json data structure resembles the following: { "index": 1, "ln": "27953", "name": "Product 1", "availability": { "day0726": "G", "day0727": "G", "day0728": "G", } } I am looking for a way to dynamically disp ...

What is the optimal method for transmitting data for a substantially large music playlist via HTTP?

I am currently in the process of developing an online music player. My main challenge lies in retrieving a comprehensive list of songs from the database and transmitting it to the user. The user should have the ability to create playlists on-the-go, hence ...

Setting up a local development environment for AngularJS

I have been using the boilerplate https://github.com/node90/angular-starter as a foundation for my projects. However, I've noticed that the repository utilizes gulp to consolidate the js files in the 'app' folder into the 'public/js&apo ...

A step-by-step guide on extracting data from a JSON array containing string arrays

If I receive the following JSON data from a web service that is unalterable, how can I deserialize it to a class efficiently? The structure consists of headers and their corresponding values. [ [ "Header1", "Header2", "Header3" ...

A guide on retrieving nested objects from my API and parsing the resulting data in each iteration for individual elements

Struggling to update my website with a new API, specifically with accessing nested objects in a loop. Still trying to wrap my head around ajax and JSON concepts. Take a look at the API output and JS code I've been working on for a better understanding ...

Having trouble retrieving accurate JSON data from an excel workbook

Currently, I am utilizing the npm module xlsx for the purpose of writing and reading JSON data. My goal is to take this JSON data and write it into an Excel file: { "name": "John", "class": 1, "address" : [ { "street": "12th Cross", "city": "London" }, { ...