Error trying to post nested view model

5 posts, 1 answers
  1. Gary
    Gary avatar
    18 posts
    Member since:
    Jun 2012

    Posted 22 May 2012 Link to this post

    I am getting the error: Uncaught TypeError: Cannot read property 'field' of undefined 

    in the kendo.all.min.js file when trying to post a view model with nested objects. 

    I have created a jsfiddle to repro the issue, I don't think I'm describing it very well, so take a look, it is short.

    http://jsfiddle.net/bNBUP/ 

    Any ideas?
    Thanks,
    Gary 
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 24 May 2012 Link to this post

    Hi,

     This is caused by the fact that the toJSON method is not recursive right now. We decided to implement this for the next internal build.

     As a workaround you could call toJSON of the nested objects: http://jsfiddle.net/bNBUP/1/ 

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Gary
    Gary avatar
    18 posts
    Member since:
    Jun 2012

    Posted 24 May 2012 Link to this post

    Thanks for the reply and explanation.  I ended up falling back to JSON.stringify (which is completely fine in my opinion - no need for you to reinvent the wheel) since in my real world case the objects were nested several objects deep.

    Gary
  5. Kevin
    Kevin avatar
    2 posts
    Member since:
    Sep 2012

    Posted 02 Jun 2012 Link to this post

    Was this addressed or where can I find an internal build? I couldn't seem to find it for the Kendo UI builds in my subscription. I see where I can download Telerik ASP.NET Ajax internal builds as well as others...

    The following was what I ended up implementing to get around the current issue. I do not know what type of model I will be submitting as it is generic and a pass through for any type:
    var tempData = viewModel.toJSON();
    $.each(tempData, function (i, v) {
         if (v && typeof (v) == "object") {
              tempData[i] = tempData[i].toJSON();
         }
    });
    return tempData;

    This only goes down one level. A recursive function would need to be used to traverse further. Do you know when it is planned to make toJSON() a recursive call?


  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 04 Jun 2012 Link to this post

    Hi Kevin,

     You could download the latest internal build from the corresponding page on kendoui.com (you have to be logged in): http://www.kendoui.com/account/your-products/product-versions/single-download.aspx?pmvid=2784&pid=949 

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready