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

KENDO UI TREEMAP DYNAMIC DATA (CUSTOM CLASS OBJECT)

3 Answers 130 Views
TreeMap
This is a migrated thread and some comments may be shown as answers.
Sunil
Top achievements
Rank 1
Sunil asked on 18 Aug 2015, 01:44 AM

Hi There,

I am new to kendo UI, I am struggling to bind dynamic data to treemap. I could not able to find example on forum

 Controller returns:

Json(treeMap, JsonRequestBehavior.AllowGet);​ object of following class

public class TreeMapData

{

 

      public int ParameterID{...}
      public string ParameterName{...}
      public double ParameterWeight{...} 
      //public string ParameterStatus
      public List<TreeMapData> ParameterChilds{..}
      //public string ParameterTooltip{...}
      public bool HasChild { get { return  ParameterChilds.Count > 0?true:false;    }
}

 

 

View:

<script type="text/javascript">
    function createTreeMap() {
        $("#treeMap").kendoTreeMap({
            dataSource: {
                transport: {
                    read: {
                        url: '@Html.Raw(Url.Action("GetAnalysisData", "Analysis", ""))',
                        dataType: "json"
                    }
                },
                schema: {
                    model: {
                        parameterid: "ParameterID",
                        parametername: "ParameterName",
                        parameterwieght: "ParameterWeight",
                        hasChildren: "HasChild",
                        children: "ParameterChilds"
                    }
                }
            },
            textField: "parametername",
            valueField: "parameterwieght"
        });       
    }

    $(document).ready(function () {
        createTreeMap();
        $(document).bind("kendo:skinChange", createTreeMap);
    });
    
    </script>​

 

Error : Microsoft JScript runtime error: Object doesn't support property or method 'slice'.

When i bind status data, it perfectly works fine.

 

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 19 Aug 2015, 03:07 PM

Hello Sunil,

As far as I understand that treeMap, which is returned by the controller is an object of the TreeMapData class. Please note that the DataSource expects  a collection/array of TreeMapData objects to be returned from the server. 

If so - please modify the logic to return a collection of items instead of single item. 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sunil
Top achievements
Rank 1
answered on 21 Aug 2015, 05:52 AM

Dimitrov,

 If you could see treemap object contains list of TreeMapData objects(recursive object)

public class TreeMapData
{
            public int ParameterID{...}
            public string ParameterName{...}
            public double ParameterWeight{...} 
****      public List<TreeMapData> ParameterChilds{..} ****
}

 

Simply, list of object will not going to help me, as i want to represent hierarchy of data. 

So treemap object is hierarchical structure contain list of same Treemap objects.

0
Boyan Dimitrov
Telerik team
answered on 24 Aug 2015, 11:27 AM

Hello Sunil,

 

I meant that the controller should return a collection of TreeMapData objects to the client-side. 

 

public ActionResult GetItems()
        {
            List<TreeMapData> result = new List<TreeMapData>();
.....
          result.Add(treeMap);
 
            return Json(result, JsonRequestBehavior.AllowGet);
}

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeMap
Asked by
Sunil
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Sunil
Top achievements
Rank 1
Share this question
or