Possible bug in dependent method login

3 posts, 0 answers
  1. Sergei
    Sergei avatar
    44 posts
    Member since:
    Aug 2012

    Posted 08 Mar 2014 Link to this post

    If I follow http://docs.telerik.com/kendo-ui/getting-started/framework/mvvm/observableobject#creating-a-dependent-method and create a dependent method on my observable object, I can not use other dependent methods within its logic. This forces me to duplicate logic.

    Example:
    var data = kendo.observable({
                listing: {
                   price: 12300
                },
                formatted: {
                    total_due: function() {
                        // this works
                        return kendo.toString((this.parent().get("listing.price")* this.parent().get("quantity"))/100, "c");
                        // this crashes with an error
                        return kendo.toString(this.parent().get("total_due")/100, "c");
                    }
                },
                quantity: 1,
                total_due: function() {
                    return this.get("listing.price")* this.get("quantity")
                }
            })

  2. Sergei
    Sergei avatar
    44 posts
    Member since:
    Aug 2012

    Posted 08 Mar 2014 in reply to Sergei Link to this post

    Mistyped the thread title, should be "Possible bug in dependent method logic"
  3. Kendo UI is VS 2017 Ready
  4. Sergei
    Sergei avatar
    44 posts
    Member since:
    Aug 2012

    Posted 08 Mar 2014 in reply to Sergei Link to this post

    Answering my own question. Dependent methods can be called directly without get() and seem to work fine this way. 
    Probably worth updating the documentation for.

    var data = kendo.observable({
                listing: {
                   price: 12300
                },
                formatted: {
                    total_due: function() {
                        return kendo.toString(this.parent().total_due()/100, "c");
                    }
                },
                quantity: 1,
                total_due: function() {
                    return this.get("listing.price")* this.get("quantity")
                }
            })
Back to Top