Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Getting Uncaught TypeError: Cannot read property 'uid' of undefined(anonymous function) when trying to bind data to Kendo Grid

Ask Question

I have a Kendo grid that is being generated in an external javascript file as well as having data bound to it, and I been getting

Uncaught TypeError: Cannot read property 'uid' of undefined(anonymous function)

I have no idea where this 'uid' is coming from, I have been stepping through the code and and I think the error is coming in when trying to pass the returned data to the datasource of the grid. My grid is this (and the grid does appear in the view)

    function ShowAdministratorsGrid() {
    $("#adminGrid").kendoGrid({
        dataSource:[{
            data: GetAdministratorsInformation()
        columns: [{
            field: "AdministratorName",
            title: "AdministratorName"
            field: "DateCreated",
            title: "DateCreated"
            field: "CreatedBy",
            title: "CreatedBy"
        Scrollable: true,
        Sortable: true,
        Pageable: [{
            Refresh: true,
            PageSizes: true,
            ButtonCount: 5
        Selectable: true,
        Events: function (e) {
            e.onRowSelect();

The datasource data is this

    function GetAdministratorsInformation() {
    $.ajax({
        type: "GET",
        url: AddURLParam.AddGetAdminInformationURL,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            GetAdministratorData(data);

The GetAdministratorData function is this..

    function GetAdministratorData(admindata) {
    administratorName = admindata.administratorName,
    dateCreated = admindata.dateCreated,
    createdBy = admindata.createdBy

I am getting the returned data, as you can see in ScreenShot1

If you take a look at ScreenShot2, I am getting an undefined when adding the returned values to the GetAdministratorData, here is the screenshot

So I am thinking that is why I am getting the error on populating the KendoGrid, does anyone see what I am doing wrong or where things are going wrong?

I narrowed down where the error is being thrown.. @Jan, I just noticed those comma's, i fixed that part and its still coming back as undefined like in ScreenShot2 – Chris Aug 29, 2015 at 23:18

data is an array. so you need to access the item by admindata[0].administratorName.

Or loop through the array, I don't really know what you're trying to do. In any case, data is an array, which (right now) just contains the one object.

Also, on this line

dataSource:[{
        data: GetAdministratorsInformation()

GetAdministratorsInformation doesn't really return anything since it's an async operation. If you want to set the data, you'll need to do it on your success callback in GetAdministratorsInformation

And in your columns settings, the field names are pascal case AdministratorName while in the data object they're camel case administratorName

To recap:

function CreateAdministratorsKendoGrid(administratorData) {
    $("#adminGrid").kendoGrid({
        dataSource:[{
            data: administratorData
        columns: [{
            field: "administratorName",
            title: "Administrator name"
            field: "dateCreated",
            title: "Date created"
            field: "createdBy",
            title: "Created by"
        Scrollable: true,
        Sortable: true,
        Pageable: [{
            Refresh: true,
            PageSizes: true,
            ButtonCount: 5
        Selectable: true,
        Events: function (e) {
            e.onRowSelect();
function InitializeAdministratorsGrid() {
    $.ajax({
        type: "GET",
        url: AddURLParam.AddGetAdminInformationURL,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            CreateAdministratorsKendoGrid(data);
InitializeAdministratorsGrid();
                Ok that was fixed, I am getting the values now, thank you for pointing that out, I appreciate it. But I am getting that error still that I mentioned in the question
– Chris
                Aug 29, 2015 at 23:27
                Then you'll need to do some more digging to find the cause of that error (which I'm guessing is something entirely different)
– Jan
                Aug 29, 2015 at 23:30
                I agree, and I have been for a couple hours before I posted the question and am unsure where to look for the issue
– Chris
                Aug 29, 2015 at 23:31
                I just noticed your edit now...It worked like a charm and thank you for explaining what I was doing wrong, much appreciated.
– Chris
                Aug 30, 2015 at 0:31

Resolved issue as follow:

var objectDDL = e.container.find("select:eq(0)").data("kendoDropDownList");
var rows = jQuery.makeArray(objectDDL.dataSource.data());
$.each(rows, function (index, value) {
  objectDDL.dataSource.remove(rows[index]);
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.