Issue Accessing Nested Object Properties in SharePoint 2013

4 posts, 0 answers
  1. Moses
    Moses avatar
    3 posts
    Member since:
    Apr 2016

    Posted 23 Oct 2017 Link to this post

    I'm experiencing issues accessing properties of an object nested (a couple levels down). The REST call is pulling in a couple lookup columns using $expand.
    I seem to be able to access a couple layers, but I'm not able to access the needed property.

    Schema

    schema: {
                data: "d.results",
            }

     

    The lookup Column is (e.g.) "team_Info", and the 2 linked columns are "Team_MemberName" (Text) &  "Team_Branch" (Calculated).

    I'm using this data in a comboBox, so I'd set up...

    ComboBox Definition

    $("#combobox_teamInfo").kendoComboBox({
        dataSource: $myDataSource,
        dataTextField: "team_Info.results[0].Team_MemberName",
        dataValueField: "",
    });

     

    The problem is team_Info.results[0].Team_MemberName is returned as undefined.
    On testing, team_Info[0] does return a series of objects, but I'm unable to access any sub-property of that object.

     

    Thx!

  2. Bozhidar
    Admin
    Bozhidar avatar
    1154 posts

    Posted 26 Oct 2017 Link to this post

    Hello,

    Unfortunately such type of binding of the DataTextField and DataValue fields is not supported. You need to either modify the end point service, so that it returns the data in a flatten format, or flatten in on the client and setting it as the datasource manually.

    Regards,
    Bozhidar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Moses
    Moses avatar
    3 posts
    Member since:
    Apr 2016

    Posted 26 Oct 2017 in reply to Bozhidar Link to this post

    May I clarify what the boundaries are though? I ask because it seems to have pulled in 2 nodes below the datasource Object.

  4. Bozhidar
    Admin
    Bozhidar avatar
    1154 posts

    Posted 27 Oct 2017 Link to this post

    Hello,

    After further testing I found out that we actually do support such binding. This is the sample I used to check this:
    jQuery("#categories").kendoComboBox({
        "dataSource": {
            "transport": {
                "read": {
                    "url": "/ComboBox/GetCategories"
                },
                "prefix": ""
            },
            "schema": {
                "errors": "Errors"
            }
        },
        "dataTextField": "Item.Child.GrandChildren[1].Title",
        "filter": "contains",
        "dataValueField": "Title",
        "placeholder": "Select category..."
    });

    using Kendo.Mvc.Examples.Models;
    using System.Collections.Generic;
    using System.Web.Mvc;
     
    namespace Kendo.Mvc.Examples.Controllers
    {
        public class ParentClass
        {
            public string Title { get; set; }
            public ItemClass Item { get; set; }
        }
        public class ItemClass
        {
            public string Title { get; set; }
            public ChildClass Child { get; set; }
        }
        public class ChildClass
        {
            public string Title { get; set; }
            public GrandChildClass GrandChild { get; set; }
            public List<GrandChildClass> GrandChildren { get; set; }
        }
        public class GrandChildClass
        {
            public string Title { get; set; }
        }
     
        public partial class ComboBoxController : Controller
        {
            [Demo]
            public ActionResult CascadingComboBox()
            {
                return View();
            }
     
            public JsonResult GetCategories()
            {
                var northwind = new SampleEntities();
     
                var list = new List<ParentClass>();
     
                var grandChild = new GrandChildClass() { Title = "GrandChild" };
                var grandChildren = new List<GrandChildClass>
                {
                    new GrandChildClass() { Title = "GrandChild 1" },
                    new GrandChildClass() { Title = "GrandChild 2" }
                };
                var child = new ChildClass() { Title = "Child", GrandChild = grandChild, GrandChildren = grandChildren };
                var item = new ItemClass() { Title = "Item", Child = child };
                var parent = new ParentClass() { Title = "Parent", Item = item };
     
                list.Add(parent);
     
                return Json(list, JsonRequestBehavior.AllowGet);
            }
        }
    }

    The problem then should be the service not returning the results. You can inspect the result to see whether all of the properties are properly serialized.

    Regards,
    Bozhidar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top