Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get name of a class that is being extended

I have couple of grids that extend AbstractFormGrid. Having an object (that could be grid or not) how to check if this object extends AbstractFormGrid. I managed to get object class name using Ext.getName(object) or object.self.getName() but i am unable to get"parent" class.

like image 844
patryks Avatar asked Aug 06 '12 20:08

patryks


People also ask

Which is the name of the class you have to extend?

A subclass is a class that “extends” an existing class; that is, it has the attributes and methods of the existing class, plus more.

How do you find the class name for a subclass?

The Class object has a getName() method that returns the name of the class. So your displayClass() method can call getClass(), and then getName() on the Class object, to get the name of the class of the object it finds itself in.

How do I find the class name of an object?

The simplest way is to call the getClass() method that returns the class's name or interface represented by an object that is not an array. We can also use getSimpleName() or getCanonicalName() , which returns the simple name (as in source code) and canonical name of the underlying class, respectively.

How do I find parent class names?

The parent() method is used to return all ancestor of the selected elements. Check if ancestor (parent) class exist then it returns the class name otherwise returns not exist.


1 Answers

The property this.superclass will return the parent class.

And as you mentioned this works:

Ext.getClass(object).superclass.self.getName()
like image 193
Izhaki Avatar answered Sep 21 '22 20:09

Izhaki