extjs documentation for declarative syntax
I'm having a really hard time reading extjs documentation. I've done a couple successful projects in extjs so far, but I still struggle reading through documentation. It seems to be written in an imperative style, but all the examples expect a declarative syntax.
For example, if I were to add a tab to TabPanel, I would expect to see in the docs a function called addTab, which takes a tab name and panel like most other UI libraries I've used behave (like Qt or Swing). Instead, I see a function like add
which takes a dictionary of values, which don't seem to be documented in the docs themselves.
In an example in extjs 3 docs for TabPanel:
var tb = new Ext.Toolbar();
tb.render(document.body); // toolbar is rendered
tb.add({text:'Button 1'}); // add multiple items (defaultType for Toolbar is 'button')
tb.add({text:'Button 2'});
tb.doLayout(); // refresh the layout
In this example, whe开发者_StackOverflowre is the text
parameter documented? I've seen examples for adding an items
field, which I've used before, but what if I just want to add an existing panel? I assume that's some other keyword, right? Where are these kinds of things documented?
What you are providing via add() is a component config (or instance of a component if you have one).
"The defaultType is button" means, by default, it will treat your configs (what you pass to add between {}
) as button configs unless you specify something else via xtype
attribute.
So in this case tb.add({text:'Button 1'});
, to know what text
means, you need to look at button's documentation (config section)
精彩评论