Declined
Last Updated: 22 Nov 2021 13:44 by ADMIN
Jack
Created on: 09 Oct 2014 15:17
Category: MVVM
Type: Feature Request
1
Add complex field types Object, Array, SubModel and [SubModel] to Models (to be ignored in Grids)
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.
1 comment
Jack
Posted on: 05 Feb 2015 20:12
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
    });
});