This is a migrated thread and some comments may be shown as answers.

Grid raising a javascript exception when parsing json return from MVC 6 action?

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 06 Dec 2015, 11:13 PM

 I'm running Kendo UI v2015.3.1111 on IE 11.

I have an MVC6 controller action that looks like this:

public IActionResult GetJsonData(Guid id)
{
    var temp2 = "[{\"id\": 1, \"Product\": \"Mower\", \"MSRP\": 189.99}, {\"id\": 2,  \"Product\": \"Imagine Fountain\", \"MSRP\": 59.99}]";
    return Json(temp2);
}

On the client, my javascript function looks like this:

function ApplyGrid(componentId) {
 
    $('#grid01').kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: '/Data/GetJsonData/' + componentId,
                    dataType: 'json'
                }
            },
            schema: {
                data: 'data'
            }
        }
    });
}
 

 This generates the following exception: 

Unhandled exception at line 11, column 28216 in http://localhost:51518/kendo/kendo.all.min.js
 
0x800a138f - JavaScript runtime error: Unable to get property 'slice' of undefined or null reference

 How should my controller action return the json data?  Or is there a different setting in the kendoGrid I should be using?

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 07 Dec 2015, 05:33 AM
Nevermind.  I reformatted my json results and things worked better.
Tags
Grid
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Share this question
or