For Ext, download an ext2.0 API file and ask you how to understand the API. After you finish reading the API, you can use the API, but you must finish reading it.
Config options
Public Properties
Public Methods
Public Events
It is basically composed of the above four parts
The content in config options is configured when you instantiate an object, that is, new Panel ({A: "XXX", B: "yyy "}), here, A and B are from config options.
Take the treenode under the tree as an example:
Checked under config options
Checked: Boolean
True to render a checked checkbox for this node, false to render an unchecked checkbox (defaults to undefined with no...
True to render a checked checkbox for this node, false to render an unchecked checkbox (defaults to undefined with no checkbox rendered)
Treenode is the meaning of a tree node, so it must be a node.
While checked clearly means we can guess whether it is selected or not.
This checked is used in confgi options for instantiation. You do not know if it can be used in other cases.
The value of this configuration option must only accept values of the boolean type, that is, true or false.
For example, VAR root = new Ext. Tree. treenode ({checked: true });
For example, href: String indicates that the configuration option href accepts the string type.
This so-called configuration option, that is, the content in config options, is used only when you instantiate it, that is, when you use the new class name ({...}).
Then, let's look at the public properties section.
Let's take a look at this childnodes, under the public properties
Childnodes: write array like this
Indicates the attributes you obtained from an instantiated object, such as VAR Tn = new Ext. tree. treenode ({....}); this has already instantiated an object, so now you can get the data of the instantiated object. How can we get it? What can we get in it, so what is listed in the public properties here is what you can get, so you need tn. childnodes can get an array type of data, so the information listed in public properties is the information that can be obtained by an instantiated object, and the return type of the information you requested after the colon.
Public methods.
Generally, the first one is the constructor that you instantiate an object.
Treenode (Object/string attributes)
This constructor can accept two types of parameters: object type and string type.
The so-called object type is generally in this mode {...}, and the so-called string type is "..."
Let's look at appendchild (node/array node): Node
It indicates that acceptable parameters are node-type or array-type data,Note that the brackets in the brackets are the parameter types that need to be passed in when this method is called. The node after the colon indicates a data type that is returned after the method is called.
For example, VAR n = tn. appendchild (New Ext. tree. treenode ({....})); then we can get the value of N, and the value of N must be of the node type.
Next, let's take a look at the Public Events section:
This part indicates the events that may occur when you use the treenode class.
For example, if you add a subnode to a tree node, the append event occurs, that is, when you var n = tn. appendchild (New Ext. tree. treenode ({....})); run thisCodeThe append event occurs.
Append: (TREE tree, node this, node, number index)
After the colon, it indicates the data that will be transmitted when this event occurs. Remember and understand this. This is the case, but how do you capture the event? There are two methods: On,Listeners,You can assign values to listeners configuration options when instantiating a class,
For example, VAR Tn = new Ext. Tree. treenode ({listeners: {"APPEND": function (A, B, C, D ){....}}})
Another oneYou can call the on or addlistener Method on this instance,The on or addlistener under public methods does not come out for no reason.
On (string eventname, function handler, [object scope], [object options]): void:JS and Java are different Java methods. The number of parameters you pass must be defined by the root, but JS does not needSo when you call the on method, you can pass parameters of different numbers.
On (string eventname, function handler, [object scope], [object options]): void can pass only two parameters,
In general, this API tells you that [] indicates parameters that you can not pass,
Others are best passed in
So you can call. TN. On ("APPEND", function (){...})
Or
Tn. On ("APPEND", hello );
Function Hello (A, B, C, D ){...}
[Object Scope], [object options] This is the scope. This is generally used to pass this or something, especially when you encounter some problems.
The call of this on or addlistener method is linked to events under public events.
Event append: (TREE tree, node this, node, number index) after the colon indicates the information automatically obtained when an event occurs.
Therefore, when the on method is called, the handler parameter in the on method is critical.
Function handler the method defined here will be called.
Event append: (TREE tree, node this, node, number index) after the colon indicates the information automatically obtained when an event occurs.
To It.
Therefore, when you define the handler, you can define the four types of parameters (TREE tree, node this, node, number index ).
Tree. On ("click", function (node, event) the function (node, event) here can be taken out separately.
An event is an event. An event does not apply to methods, but to objects, for example, if you want to right-click a tree node and call a method to trigger the event when calling some methods: You can then tn. on ("contextmenu", function (node, e ){...})
The following items under public events only define some events. When using events, you capture them by using on: And on is short for addlistener. The two methods are the same.
On the right of each configuration option, attribute, method, or event of the API, a column name is defined by, and the column header is defined,
It indicates the class that defines the information, because you need to know that a very important information in ext is inheritance,
Therefore, some methods, configuration options, and attributes come from their parent class or superclass,
Then this defined by tells you which parent class or superclass is from.
In this way, the source code is very clear.
Then defined by if the font is black, it indicates that this configuration option, attribute, method, or event is defined by its own class.
So when you look at the features of a class, you only need to pay attention to the configuration options, properties, methods, or events of the black text.
Then let's look at the top part.
Class Ext. Tree. treenodepackage: Ext. Tree
Defined in: treenode. js
Class: treenode
Subclasses: asynctreenode
Extends: Node
Subclasses and extends
Subclasses indicates which sub-classes of the class, and extends indicates which class the class inherits from.
This is because of the restrictions on the event application.
Only those classes that inherit the observable class, that is, the class is a subclass or descendant class of the observable class, then this class has the event processing mechanism, that is, only the Public Events section will be available.
Therefore, if you want to extend a class and have an event processing and response mechanism, the class must be a subclass or descendant of the observable class.
You can always click the back of extends and the observable class I mentioned will come out.