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

Issue Accessing Nested Object Properties in SharePoint 2013

3 Answers 113 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Moses
Top achievements
Rank 1
Moses asked on 23 Oct 2017, 10:03 PM

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!

3 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 26 Oct 2017, 06:49 AM
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.
0
Moses
Top achievements
Rank 1
answered on 26 Oct 2017, 11:43 AM

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

0
Bozhidar
Telerik team
answered on 27 Oct 2017, 05:11 AM
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.
Tags
Data Source
Asked by
Moses
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Moses
Top achievements
Rank 1
Share this question
or