The Kendo Grid is appearing correctly, however, it is not showing the JSON data as

Lately, I've been struggling with grids, particularly when trying to display properly formatted JSON data fetched from a webservice (which has already been validated in VS2013 and JSONLint). If someone could take a look at my solution and point out what's missing, I would greatly appreciate it. This is driving me crazy!

function SetTelerikGrid() {

// preparing the data object and retrieving data from the web service,...
$.ajax({
    type: "GET",
    async: false,
    url: "http://localhost:38312/SDMSService.svc/GetProductPositionsByLocation/0544",
    datatype: "json",
    success: function (ProductData, textStatus, jqXHR) {

        // populating the kendo location grid with data from the successful ajax call,...
        $("#LocationProductsGrid").kendoGrid({
                    dataSource: {
                        data: ProductData, // the solution was here: **JSON.parse(LocationData)**
                        schema: {
                            model: {                                    
                                fields: {
                                    Date: { type: "string" },
                                    ProductCode: { type: "string" },
                                    StoreNum: { type: "string" },                                        
                                    ProductQty: { type: "int" }
                                }
                            }
                        },
                        pageSize: 20
                    },
                    height: 550,
                    scrollable: true,
                    sortable: true,
                    filterable: true,
                    pageable: {
                        input: true,
                        numeric: false
                    },
                    columns: [
                        { field: "Date", title: "Date", width: "130px" },
                        { field: "ProductCode", title: "Product Code", width: "130px" },
                        { field: "StoreNum", title: "Store Number", width: "130px" },                            
                        { field: "ProductQty", title: "Product Qty", width: "130px" }
                    ]
                });

    }
});   

}

Answer №1

There has been a significant update in ASP.NET Core that affects the functioning of the JSON serializer.

This issue can be addressed by incorporating a json option as shown below:

1: modification

services.AddMvc();

should be changed to

services

.AddMvc()
    .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());

OR

2:

public IActionResult Read()
{
  // Customize serializer settings for individual actions
  return Json(
     MyModel,
     new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() }
  );
}

references : http://www.telerik.com/forums/using-2016-2-630-preview---data-not-displayed#qlHR6zhqhkqLZWuHfdUDpA

https://github.com/telerik/kendo-ui-core/issues/1856#issuecomment-229874309

https://github.com/telerik/kendo-ui-core/issues/1856#issuecomment-230450923

Answer №2

After much trial and error, I finally cracked the code. It turns out that even though the 'ProductData' field is already in JSON format, it still needs to be parsed as JSON in the data source configuration. Here's how you can do it...

Transformed Data: JSON.parse(ProductData)

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

How can we utilize an ajax call to upload images instead of form fields when using the blobstore service on GAE?

Is it possible to upload an image using an AJAX call instead of form fields when utilizing the blobstore service of GAE? I desire to regain control over the page without causing a reload, specifically where the upload file input is located. This is why I ...

In the console, a JSON string is displayed, however the PHP variable outputs as null

Below is the snippet of javascript code I am working with: $('.showEditForm').click(function () { var webpagefileID = this.id; if($('#editForm').css('display', 'none')) { $('#editForm').css ...

Encountering a Jackson class not found exception in Spring MVC when working with JSON data

I am having trouble getting Spring's JSON support to work properly. In my spring-servlet.xml file, I have included the following lines: <mvc:annotation-driven/> <context:component-scan base-package="my.packagename.here" /> <context:ann ...

What could be causing me to receive no results?

Currently, I am expanding my knowledge in JavaScript, Ajax, and NodeJs. My current project involves creating a webpage that can display a string retrieved from the server. The server-side code is as follows: var express = require('express'); v ...

Navigate through a given value in the event that the property undergoes a name change with each

Exploring an example found on the JSON site, I am facing a situation where I am using an API with JSON data. The property name "glossary" changes for each request made. For instance, if you search for "glossary", the first property is glossary. However, if ...

Using jQuery to pass dynamic values to a plugin function

I'm currently utilizing the JSONTable plugin and attempting to dynamically pass values to the 'head' and 'json' parameters by extracting them from an array object. For instance, I aim to load a new json file, convert it to a JavaSc ...

I'm experiencing a lack of feedback while implementing jQuery/AJAX with JSONP

Attempting to perform a cross-domain request using jQuery/AJAX, I have the code below; $.ajax({ url: "http://www.cjihrig.com/development/jsonp/jsonp.php?callback=jsonpCallback&message=Hello", crossDomain:true }) .done(function( msg ) { alert( ...

Extract information from a complex nested structure within an array

Can someone assist me with extracting only the username from the response provided below? I am able to access other data but struggling with this particular aspect. [ { "_id": "5f44d450aaa72313549d519f", "imageTitle": "u ...

Storing values as JSON in Redis: A comprehensive guide

In my application, I have implemented Redis as the caching store. Below is the configuration setup for Redis: @Configuration @EnableCaching public class SpringRedisConfig { @Bean public JedisConnectionFactory connectionFactory() { JedisConnectionFacto ...

Tips for retrieving the specific JSON node instance with Groovy?

When working with JSON files in Groovy, it can sometimes be tricky to differentiate between different types of nodes. For example, the "value" and "onclick" nodes in the provided JSON file both return as ArrayLists, even though logically we expect "value" ...

Unable to obtain the accurate response from a jQuery Ajax request

I'm trying to retrieve a JSON object with a list of picture filenames, but there seems to be an issue. When I use alert(getPicsInFolder("testfolder"));, it returns "error" instead of the expected data. function getPicsInFolder(folder) { return_data ...

Transforming XML into Json using HTML string information in angular 8

I am currently facing a challenge with converting an XML document to JSON. The issue arises when some of the string fields within the XML contain HTML tags. Here is how the original XML looks: <title> <html> <p>test</p> ...

Auto-suggest feature using Jquery for dynamically pulling suggestions from a database table

How can I implement an auto-suggest text field that can fetch usernames from my database? I intend to utilize the autocomplete plugin from Jquery UI for this purpose. My aim is to create a fast and highly secure solution. ...

Exploring the depths of a JSON structure with Decodable

Here is the structure of my JSON: { "code": 200, "status": "Ok", "etag": "7232324423", "data": { "offset": 0, "limit": 25, "results": [{ "id": 1011244, "name": "Miss Nesbit", ...

Enhancing Performance: Overcoming ASP.Net Update Panel Timeout

Is there a solution for this problem? After an extended period of utilizing the UpdatePanel, it suddenly ceases to function properly. I have implemented several UpdatePanels on a single page and all of them are configured for conditional updates. ...

"Moisten" a JavaScript object instance using a JSON array, similar to the way PHP does

When populating PHP objects with data, I typically use the following method: public function hydrate(array $data){ foreach($data as $key=>$value){ $method = 'set'.ucfirst($key); if(METHOD_EXISTS($this,$method)){ ...

Encountering Keyerror while trying to parse JSON in Python

Recently, I developed a program for extracting data from an API that returns information in JSON format. However, when attempting to parse the data, I encountered a key error. Traceback (most recent call last): File "test.py", line 20, in <module> ...

The Vite manifest file could not be located in the designated path: C:xampphtdocslolaboutpublicuild/manifest.json

"Error: Vite manifest not found at: C:\xampp\htdocs\vrsweb\public\build/manifest.json" Please start the development server by running npm run dev in your terminal and refreshing the page." Whenever I attempt to acce ...

Python error: Index out of range when utilizing index() function

@bot.command() async def start(ctx): edit = [] with open("wallet.json", "w") as file: for obj in file: dict = json.load(obj) edit.append(dict) userid = [] for player in edit: user ...

The 'jQuery ajax load' function is not working as expected

This particular scenario <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> <div id="test"></div> <script> $(document).ready(() => { $('#test').load('doesntmatter'); }); </scr ...