Inheritance With Kendo UI - Calling base class constructor

2 posts, 0 answers
  1. Sakthivel
    Sakthivel avatar
    6 posts
    Member since:
    Jun 2012

    Posted 01 Aug 2012 Link to this post

    I am experimenting with "kendo.Class.extend()".

    When I inherit a new class from a base class, how can i call the base class constructor from within the derived class constructor?

    The below didn't work for me.

    var ClsPerson = kendo.Class.extend(
                    {
                        FirstName:"<none>", LastName: "<none>", Married: false, 
                        Display: function() { alert("I am " + this.FirstName + " " + this.LastName); },
                        init: function(FirstName, LastName)
                        {
                            if (FirstName) this.FirstName = FirstName;
                            if (LastName) this.LastName = LastName;
                        }
                    });
    var ClsParent = ClsPerson.extend(
                    {
                        SpouseName: "<none>",
                        init: function(FirstName, LastName, SpouseName)
                        {
                            //if (FirstName) this.FirstName = FirstName;
                            //if (LastName) this.LastName = LastName;
                            ClsPerson(FirstName, LastName);
                            if (SpouseName) this.SpouseName = SpouseName;
                        }
                    });

    var Parent1 = new ClsParent("Sakthivel", "S", "Sangitha S");
    Parent1.Display();
    alert(Parent1.SpouseName);

    I tried calling the base class constructor like "ClsPerson(FirstName, LastName); ", but didn't get the desired results.
  2. Maxim
    Maxim avatar
    3 posts
    Member since:
    Apr 2012

    Posted 10 Aug 2012 Link to this post

    ClsPerson.call(this, ...);
Back to Top