You can (sort of) get Object and Array by not defining a type on model field definitions but explicit types would be better to be enforced. Also grids could ignore these types unless a custom editor is provided. There is also a need for fields that reference submodels and arrays of submodels. HierarchicalDataSources do not really fit the requirement. See how mongoose (for mongoDB) handles documents and subdocuments.
var Item = kendo.data.Model.define({
fields: {
title: {
type: 'string'
},
attributes: {
defaultValue: {}
}
}
});
var Attributes = kendo.data.Model.define({
fields: {
src: {
type: 'string'
},
alt: {
type: 'string'
},
style: {
type: 'string'
}
}
});
describe('Test complex kendo.data.Model', function() {
it('Test instances through aggregations', function() {
var attributes = new Attributes({alt: 'Google', src: 'http://www.google.com/logo.jpg', style: 'height: 100px; width: 100px;'}),
item = new Item({title:'sample image', attribute: attributes}),
viewModel = kendo.observable({ item: item });
expect(viewModel.item).to.be.an.instanceof(Item);
expect(viewModel.item).to.be.an.instanceof(kendo.data.Model);
expect(viewModel.item.attributes).to.be.an.instanceof(Attributes); //Fails
expect(viewModel.item.attributes).to.be.an.instanceof(kendo.data.Model); //Fails
});
});