ObservableObject double dependent fields

2 posts, 0 answers
  1. Bart
    Bart avatar
    11 posts
    Member since:
    Jul 2013

    Posted 26 Jul 2013 Link to this post

    Consider the following code. Within the incidentPercentage method, I am using another dependent method, but I am not able the use the recommended "this.get" syntax here. The only way I could get it to work was to call the other dependent methods directly. Please advise. Is this OK to do?

    var viewModel = kendo.observable({
      dataItem: {},
      details: function() {
        return this.get('dataItem').details;
      hourCount: function() {
        var dataItem = this.get('dataItem');
        return (dataItem.hasOwnProperty('status') ? dataItem.status.length : 0);
      incidentCount: function() {
        return _.without(this.get('dataItem').status, 1, true).length;
      incidentPercentage: function() {
        return Math.round(
          this.incidentCount() / this.hourCount() * 100
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 30 Jul 2013 Link to this post

    Hello Bart,

     Yes this is ok to do as long as the dependent method uses get("") to access fields. This should still setup the correct dependency chain.

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