Calculated fields and parent()

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    1 posts
    Member since:
    Jun 2013

    Posted 15 Jul 2013 Link to this post


    I have an observable object looking something like this:

    1.viewModel = kendo.observable({
    2.    anArray: ['item1', 'item2', '...'],
    3.    filteredArray: function() {
    4.        return this.get('actions').filter(function (el) {
    5.            return someLogic(el);
    6.        });
    7.    }
    So far so good. No I want to use this filtered array in a source binding (to generate a table, say) and I want to to the following:

    1.<script id="row-template" type="text/x-kendo-template">
    2.    <tr>
    3.        [...]
    4.        <td><select data-bind="source: availableDescriptions, value: Description"/></td>
    5.    </tr>
    Where availableDescription is an array contained in my viewModel.
    This generates an error (Uncaught TypeError: Object [object Array] has no method 'parent' )

    Apparently kendo is resolving 'availableDescriptions' by calling 'parent()' on the observable array that is the context for my template. To work around this I changed my implementation of filteredArray to look like this:

    1.filteredArray: function () {
    2.    var a = this.get('actions').filter(function (el) {
    3.        return doSomething(el);
    4.    });
    5.    a.parent = function () { return this; };
    6.    return a;
    It works, but isn't particularly graceful. Is there a better way to do this ?
  2. Alexander Valchev
    Alexander Valchev avatar
    2895 posts

    Posted 17 Jul 2013 Link to this post

    Hi Pierre,

    It seems that this issue is addressed in the latest build. Please download Q2 official release (v2013.2.716) and give it a try.

    For convenience I prepared a small sample:

    Alexander Valchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top