Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Add same functionality to two classes

    We are looking to extend the functionality of listGrid and treeGrid with the same functions -
    The new functions are both for listGrid and treeGrid.
    We know that treeGrid is inherited from listGrid.
    As far as I know, we cant change listGrid class...
    Is there a way to add the common functionality without writing the code twice?
    There is a diagram which demonstrates our expected result -


    Thanks.
    Last edited by Isomorphic; 22 Jan 2020, 12:48.

    #2
    Java would make this hard but in JavaScript it's trivial: create a method that adds the common methods and properties to the target class, and call it twice, once for your ListGrid subclass and once for your TreeGrid subclass.

    Comment


      #3
      Thanks, we used a slightly different approach for this problem, we used Mixing Pattern (with classes) to extend both myTreeGrid and myListGrid (with the commonListGrid Class).

      Comment

      Working...
      X