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

Subclassing kendo.data.Node and kendo.data.HierarchicalDataSource

1 Answer 77 Views
Hierarchical Data Source
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 2
Iron
Jack asked on 04 Feb 2015, 05:36 PM
I would like to create a specific hierarchy of Manufacturers, Cars and Parts.

To achieve this, I would like to subclass kendo.data.Node as follows:

var Manufacturer = kendo.data.Node.extend({
//...
});
var Car = kendo.data.Node.extend({
//...
});
var Part = kendo.data.Node.extend({
//...
});

I would then like to subclass kendo.data.HierachicalDataSource, to represent such a hierarchy.

Question 1: How can I achieve that?

Data comes from a RESTful JSON service located at:
http://<ip address>/api/v1/manufacturers (GET, POST)
http://<ip address>/api/v1/manufacturers/<mid> (GET, PUT, DELETE)
http://<ip address>/api/v1/manufacturers/<mid>/cars (GET, POST)
http://<ip address>/api/v1/manufacturers/<mid>/cars/<cid> (GET, PUT, DELETE)
http://<ip address>/api/v1/manufacturers/<mid>/cars/<cid>/parts (GET, POST)
http://<ip address>/api/v1/manufacturers/<mid>/cars/<cid>/parts/<pid> (GET, PUT, DELETE)

Then I would like to instantiate my subclassed hierarchy to use this JSON service. 

Question 2:  How can I achieve that?





1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 06 Feb 2015, 02:46 PM

Hello Jacques,

I'm afraid that this approach is not supported in a clean way. You can achieve it with the code shown in this Dojo snippet, but mixing the transport and models is unavoidable.

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Hierarchical Data Source
Asked by
Jack
Top achievements
Rank 2
Iron
Answers by
Alex Gyoshev
Telerik team
Share this question
or