Extjs layout example (panel, viewport, tabpanel)

Source: Internet
Author: User

Panel application <br/> New Ext. panel ({<br/> title: 'panel header (header) ', <br/> tbar: ['top toolbar (top toolbars)'], <br/> bbar: ['bottom toolbar (bottom toolbars') '], <br/> Height: 200, <br/> width: 300, <br/> frame: True, <br/> applyto: 'panel ', <br/> bodystyle: 'background-color: # ffff', <br/> HTML:' <div> panel body) </div> ', <br/> Tools: [<br/> {ID: 'toggle'}, <br/> {ID: 'close '}, <br/> {ID: 'maximize'} <br/>], <br/> buttons: [<br/> New Ext. but Ton ({<br/> text: 'bottom of the panel (footer) '<br/>}) <br/>] <br/> }) </P> <p> remote page loading by Panel <br/> var Panel = new Ext. panel ({<br/> title: 'panel loading remote page', <br/> Height: 150, // set the Panel height <br/> width: 250, // set the panel width <br/> frame: True, // render panel <br/> autoscroll: True, // the scroll bar is automatically displayed <br/> collapsible: True, // allow expansion and contraction <br/> applyto: 'panel ', <br/> autoload: 'page1.html', // automatically load the default connection of the Panel body <br/> bodystyle: 'background-color: # ffffff' // set the background color of the Panel <br/>}) </P> <P> panel attach local page <br/> var Panel = new Ext. panel ({<br/> title: 'panel loads local resource', <br/> Height: 150, // set the Panel height <br/> width: 250, // set the panel width <br/> frame: True, // render the Panel <br/> collapsible: True, // enable expansion and contraction <br/> autoscroll: True, // automatically display the scroll bar <br/> autoheight: false, // use a fixed height <br/> // autoheight: True, // use an automatic height <br/> applyto: 'panel ', <br/> contentel: 'localelement', // load local resources <br/> bodystyle: 'background-color: # ffffff' // set the background color of the Panel <br /> }) <Br/> local resources <br/> <Table border = 1 id = 'localelement'> <br/> <tr> <TH colspan = 2> local resources-employee list </Th> </tr> <br/> <TH width = 60> NO. </Th> <TH width = 80> name </Th> <br/> <tr> <TD> 1 </TD> <TD> Zhang San </TD> </tr> <br/> <tr> <TD> 2 </TD> <TD> Li Si </TD> </tr> <br/> <tr> <TD> 3 </TD> <TD> Wang Wu </TD> </tr> <br/> <tr> <TD> 4 </TD> <TD> Zhao liu</TD> </tr> <br/> <tr> <TD> 5 </TD> <TD> Chen Qi </TD> </tr> <br/> <tr> <TD> 6 </TD> <TD> Yang Ba </TD> </tr> <br/> <tr> <TD> 7 </TD> <TD> Liu JIU </TD> </tr> <br/> </table> </P> <p> Use HTML configuration items to define a panel content <br/> var htmlarray = [<br/> '<Table border = 1> ', <br/> '<tr> <TD colspan = 2> employee list </TD> </tr> ', <br/> '<tr> <TH width = 60> NO. </Th> <TH width = 80> name </Th> <tr> ', <br/> '<tr> <TD> 1 </TD> <TD> Zhang San </TD> </tr> ', <br/> '<tr> <TD> 2 </TD> <TD> Li Si </TD> </tr> ', <br/> '<tr> <TD> 3 </TD> <TD> Wang Wu </TD> </tr> ', <br/> '<tr> <TD> 4 </TD> <TD> Zhao Liu </TD> </tr> ', <br/> '<tr> <TD> 5 </TD> <TD> Chen Qi </T D> </tr> ', <br/>' <tr> <TD> 6 </TD> <TD> Yang Ba </TD> </tr> ', <br/> '<tr> <TD> 7 </TD> <TD> Liu JIU </TD> </tr> ', <br/> '</table>' <br/>]; <br/> var Panel = new Ext. panel ({<br/> title: 'Use HTML configuration items to customize the Panel content', <br/> Height: 150, // set the Panel height <br/> width: 250, // set the width of the Panel <br/> frame: True, // render the Panel <br/> collapsible: True, // allow expansion and contraction <br/> autoscroll: true, // the scroll bar is automatically displayed. <br/> applyto: 'panel ', <br/> HTML: htmlarray. join (''), <br/> bodystyle: 'background-Co Lor: # ffff' // set the background color of the Panel body <br/>}) </P> <p> use items to add the panel content <br/> var Panel = new Ext. panel ({<br/> header: True, <br/> title: 'calendar ', <br/> frame: True, // render panel <br/> collapsible: true, // allow expansion and contraction <br/> autoheight: True, // automatic height <br/> width: 189, // fixed width <br/> applyto: 'panel ', <br/> items: New Ext. datepicker () // Add a date component to the Panel <br/> }) </P> <p> Use of panel nesting </P> <p> var Panel = new Ext. panel ({<br/> header: True, <br/> title: 'Enabled Use Items for panel nesting ', <br/> frame: True, // render panel <br/> collapsible: True, // allow expansion and contraction <br/> height: 200, <br/> width: 250, <br/> applyto: 'panel ', <br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff', // set the background color of the Panel body <br/> Height: 80, // The height of the sub-panel is 80 <br/> collapsible: True, // allow expansion and contraction <br/> autoscroll: True // the scroll bar is automatically displayed <br/>}, <br/> items: [<br/> New Ext. panel ({<br/> title: 'nested panel 1', <br/> contentel: 'localelemen T' // load local resources <br/>}), <br/> New Ext. panel ({<br/> title: 'nested panel 2', <br/> autoload: 'page1.html '// load remote pages <br/> }) <br/>] <br/>}) </P> <p> fitlayout layout panel </P> <p> var Panel = new Ext. panel ({<br/> layout: 'fit', <br/> title: 'ext. layout. fitlayout layout example ', <br/> frame: True, // rendering panel <br/> Height: 150, <br/> width: 250, <br/> applyto: 'panel ', <br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffff' // set the background of the Panel. Color <br/>}, <br/> // The default xtype of the Panel items configuration item is panel, <br/> // you can change the default value through the defaulttype configuration item <br/> items: [<br/> {<br/> title: 'nested panel 1 ', <br/> HTML: 'panel 1' <br/>}, <br/> {<br/> title: 'nested panel 2', <br/> HTML: 'panel 2' <br/>}< br/>] <br/>}) </P> <p> layout. accordion layout panel <br/> var Panel = new Ext. panel ({<br/> layout: 'accordion', <br/> layoutconfig: {<br/> activeontop: True, // set the opening sub-panel to top <br/> Fill: True, // The Sub-panel is filled with the remaining space of the parent panel <B R/> hidecollapsetool: false, // The "expand and contract" button is displayed. <br/> titlecollapse: True, // you can expand or contract the Panel by clicking the sub-panel title. <br/> Animate: True // use animation effects <br/>}, <br/> title: 'ext. layout. accordion layout example ', <br/> frame: True, // rendering panel <br/> Height: 150, <br/> width: 250, <br/> applyto: 'panel ', <br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff; padding: 15px '// set the background color of the Panel body <br/>}, <br/> items: [<br/>{< br/> title: 'nested panel 1 ', <br/> HTML: 'Statement 1' <br/>}, <br/>{< br/> title: 'nested panel 2', <br/> HTML: 'note 2' <br/>}< br/>, <br/>{< br/> title: 'nested panel 3', <br/> HTML: 'note 3' <br/>}< br/>] <br/>}) </P> <p> layout. cardlayout layout panel <br/> var Panel = new Ext. panel ({<br/> layout: 'Card ', <br/> activeitem: 0, // The first sub-panel is displayed by default. <br/> title: 'ext. layout. cardlayout layout example ', <br/> frame: True, // rendering panel <br/> Height: 150, <br/> width: 250, <br/> applyto: 'panel ', <br/> defaul TS: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff; padding: 15px '// set the background color of the Panel <br/> }, <br/> items: [<br/> {<br/> title: 'nested panel 1', <br/> HTML: 'description ', <br/> ID: 'p1' <br/>}, <br/> {<br/> title: 'nested panel 2', <br/> HTML: 'note 2', <br/> ID: 'p2' <br/>}< br/>, <br/>{< br/> title: 'nested panel 3', <br/> HTML: 'description 3', <br/> ID: 'p3' <br/>}< br/>], <br/> buttons: [<br/>{< br/> text: 'preview', <br/> handler: changepage <br/ >}, <Br/>{< br/> text: 'Next page', <br/> handler: changepage <br/>}< br/>] <br/>}) <br/> // switch sub-panel <br/> function changepage (BTN) {<br/> var Index = Number (panel. layout. activeitem. id. substring (1); <br/> If (BTN. TEXT = 'preput') {<br/> index-= 1; <br/> If (index <1) {<br/> Index = 1; <br/>}< br/>}else {<br/> index + = 1; <br/> If (index> 3) {<br/> Index = 3; <br/>}< br/> panel. layout. setactiveitem ('P' + index); <B R/>}</P> <p> layout. anchorlayout layout panel <br/> var Panel = new Ext. panel ({<br/> layout: 'anchor ', <br/> title: 'ext. layout. anchorlayout layout example ', <br/> frame: false, // rendering panel <br/> Height: 150, <br/> width: 300, <br/> applyto: 'panel ', <br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff; padding: 15px '// set the background color of the Panel body <br/>}, <br/> items: [<br/>{< br/> anchor: '2017 123 ', // set the width and height of the Child panel to 50% of the parent panel <br/> title :' Sub-panel '<br/>}< br/>] <br/>}) <br/> or: <br/> items: [<br/> {<br/> anchor: '-10-10', // set the width and height offset of the sub-panel to 10 pixels for the parent panel. <br/> title: 'subpanel' <br/>}< br/>] </P> <p> or: <br/> items: [<br/> {<br/> anchor: 'r B ', // locate the difference between the right side and the bottom side of the parent container <br/> width: 200, <br/> Height: 100, <br/> title: 'subpanel' <br/>}< br/>] </P> <p> or: <br/> items: [<br/>{< br/> X: '000000', // The X coordinate is the position 10% from the parent container width. <br/> Y: 10, // The ordinate is 10 pixels from the edge of the parent container <br/> width: 100, <br /> Height: 50, <br/> title: 'sub-panel 1' <br/>}, <br/> {<br/> X: 90, // The abscissa is 90 pixels from the left edge of the parent container <br/> Y: 70, // The ordinate is 70 pixels from the edge of the parent container <br/> width: 100, <br/> Height: 50, <br/> title: 'sub-panel 2' <br/>}< br/>] </P> <p> layout. formlayout layout panel <br/> var Panel = new Ext. panel ({<br/> title: 'ext. layout. formlayout layout example ', <br/> layout: 'form', <br/> labelseparator:', // specify a separator in the container <br/> frame: True, // render panel <br/> Height: 110, <br/> wid TH: 300, <br/> applyto: 'panel ', <br/> defaulttype: 'textfield ', // specify the default xtype of the container sub-element as textfield <br/> defaults: {// set the default attribute <br/> msgtarget: 'day' // specify the default error message prompt method <br/>}, <br/> items: [<br/>{< br/> fieldlabel: 'username ', <br/> allowblank: false <br/>}, <br/>{< br/> fieldlabel: 'Password', <br/> allowblank: false <br/>}< br/>] <br/>}) </P> <p> layout. columnlayout layout panel <br/> var Panel = new Ext. panel ({<br/> title: 'ext. la Yout. columnlayout layout example ', <br/> layout: 'column', <br/> frame: True, // render panel <br/> Height: 150, <br/> width: 250, <br/> applyto: 'panel ', <br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff; ', // sets the background color of the Panel body <br/> frame: True <br/>}, <br/> items: [<br/> {<br/> title: 'sub-panel 1', <br/> width: 100, // specify that the column width is 100 pixels. <br/> height: 100 <br/>}, <br/>{< br/> title: 'sub-panel 2', <br/> width: 100, // specify the column width to 100 pixels <br/> height: 100 <br/>}< br/>] <br/>}) </P> <p> or: <br/> items: [<br/> {<br/> title: 'sub-panel 1', <br/> columnwidth :. 3, // specify that the column width is 30% of the container width <br/> Height: 100 <br/>}, <br/>{< br/> title: 'sub-panel 2', <br/> columnwidth :. 7, // specify that the column width is 70% of the container width <br/> Height: 100 <br/>}< br/>] </P> <p> or: <br/> items: [<br/> {<br/> title: 'sub-panel 1', <br/> width: 100, // specify the column width as 100 pixels <br/> Height: 100 <br/>}, <br/>{< br/> title: 'sub-panel 2 ', <br/> width: 100, <br/> columnwidth :. 3, // specify the column width as 30% of the remaining width of the container <br/> Height: 100 <br/>}, <br/>{< br/> title: 'panel 3', <br/> columnwidth :. 7, // specify the column width as 70% of the remaining width of the container <br/> Height: 100 <br/>}< br/>] </P> <p> layout. tablelayout layout panel <br/> var Panel = new Ext. panel ({<br/> title: 'ext. layout. tablelayout layout example ', <br/> layout: 'table', <br/> layoutconfig: {<br/> columns: 4 // set the table layout to four columns by default <br/>}, <br/> frame: True, // render panel <br/> Height: 150, <br/> applyto: 'panel ', <Br/> defaults: {// set the default attribute <br/> bodystyle: 'background-color: # ffffff ;', // set the background color of the Panel body <br/> frame: True, <br/> Height: 50 <br/>}, <br/> items: [<br/>{< br/> title: 'sub-panel 1', <br/> colspan: 3 // set cross-column <br/> }, <br/>{ <br/> title: 'sub-panel 2', <br/> rowspan: 2, // sets the cross-Row Height: 100 <br/>}, <br/> {Title: 'sub-panel 3' },< br/> {Title: 'sub-panel 4 '}, <br/> {Title: 'sub-panel 5'} <br/>] <br/>}) </P> <p> layout. borderlayout layout panel <br/> var Panel = New Ext. panel ({<br/> title: 'ext. layout. borderlayout layout example ', <br/> layout: 'border', // table layout <br/> Height: 250, <br/> width: 400, <br/> applyto: 'panel ', <br/> items: [<br/>{< br/> title: 'North panel', <br/> HTML: 'shanghai', <br/> region: 'north', // The area of the stator panel is north. <br/> Height: 50 <br/> }, <br/>{< br/> title: 'southpanel ', <br/> HTML: 'lower', <br/> region: 'south ', // The area of the stator panel is South <br/> Height: 50 <br/>},{ <br/> T Itle: 'West panel ', <br/> HTML: 'left', <br/> region: 'west ', // The area where the stator panel is located is West <br/> width: 100 <br/>},{ <br/> title: 'East panel ', <br/> HTML: 'right', <br/> region: 'east', // The area of the stator panel is east. <br/> width: 100 <br/> }, {<br/> title: 'main content', <br/> HTML: 'intermediary ', <br/> region: 'center' // The area of the stator panel is center <br/>}] <br/>}); </P> <p> Ext. viewport layout example <br/> New Ext. viewport ({<br/> title: 'ext. viewport example ', <br/> layout: 'bor Der ', // table layout <br/> items: [<br/> {<br/> title: 'North panel', <br/> HTML: 'upgrade ', <br/> region: 'north', // indicates that the area of the stator panel is north. <br/> Height: 100 <br/>},{ <br/> title: 'West panel ', <br/> HTML: 'left', <br/> region: 'west', // indicates that the area of the stator panel is west. <br/> width: 150 <br/>},{ <br/> title: 'main content', <br/> HTML: 'intermediate ', <br/> region: 'center' // The area of the stator panel is center <br/>}] <br/>}); </P> <p> Ext. tabpanel tab example <br/> var tabpanel = new E XT. tabpanel ({<br/> Height: 150, <br/> width: 300, <br/> activetab: 0, // The first tab page is activated by default. <br/> animscroll: True, // use the animation scroll effect. <br/> enabletabscroll: True, // The scroll button automatically appears when the tab label is too wide <br/> applyto: 'panel ', <br/> items: [<br/> {Title: 'tab tab 1 ', HTML: 'tab 1 content'}, <br/> {Title: 'tab 2 ', HTML: 'tab 2 content'}, <br/> {Title: 'tab 3 ', HTML: 'tab 3 content'}, <br/> {Title: 'tab 4', HTML: 'tab 4 content '}, <br/> {Title: 'tab 5 ', HTML: 'tab 5 content'} <br/>] <br/>}); </P> <p> Ext. tabpanel (div conversion) Example </P> <p> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> Ext. onready (function () {<br/> Ext. blank_image_url = '.. /.. /extjs2.0/resources/images/default/s.gif '; <br/> var tabpanel = new Ext. tabpanel ({<br/> Height: 50, <br/> width: 300, <br/> autotabs: True, // automatically scan the DIV in the page and convert it to a tab <br/> deferredrender: false, // no delay rendering <br/> activetab: 0, // The first tab page is activated by default. <br/> animscroll: True, // use the animation scroll effect. <br/> enabletabscroll: True, // The scroll button automatically appears when the tab label is too wide <br/> applyto: 'panel '<br/>}); <br/> }); </P> <p> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body> <br/> <Table width = 100%> <br/> <tr> <TD> </tr> <br/> <tr> <TD width = 100> </TD> <br/> <Div id = 'panel '> <br/> <Div class = 'x-tab 'Title = 'tab tab 1'> tab Tab 1 content </div> <br/> <Div class = 'x-tab' Title = 'tab tab 2'> tab Tab 2 content </div> <br/> <Div class = 'x-tab 'title = 'tab tab 3'> tab 3 content </div> <br/> <Div class = 'x-tab 'Title = 'tab tab 4'> tab 4 content </div> <br/> <Div class = 'X-tab 'title = 'tab 5'> tab 5 content </div> <br/> <Div class = 'x- tab 'title = 'tab tab 6'> tab 6 content </div> <br/> <TD> </tr> <br/> </table> <br/> </body> <br/> </ptml> </P> <p> Ext. tabpanel example (add a tab page dynamically) <br/> var tabpanel = new Ext. tabpanel ({<br/> Height: 150, <br/> width: 300, <br/> activetab: 0, // The first tab page is activated by default. <br/> animscroll: True, // use the animation scroll effect. <br/> enabletabscroll: True, // The scroll button automatically appears when the tab label is too wide <br/> applyto: 'panel ', <br/> resizetabs: True, <br/> tabmargin: 50, <br/> tabwidth: 100, <br/> items: [<br/> {Title: 'tab 1 ', HTML: 'tab 1 content'} <br/>], <br/> buttons: [<br/>{< br/> text: 'add label ', <br/> handler: addtabpage <br/>}< br/>] <br/>}); <br/> function addtabpage () {<br/> var Index = tabpanel. items. length + 1; <br/> var tabpage = tabpanel. add ({// dynamically Add a tab page <br/> title: 'tab tab '+ index, <br/> HTML: 'tab' + index + 'content ', <br/> closable: True // disable allowed <br/>}) <br/> tabpanel. setactivetab (tabpage ); // set the current tab <br/>}</P> <p> nested layout to implement horizontal form </P> <p> var form = new Ext. form. formpanel ({<br/> title: 'horizontal arrangement of forms through layout nesting ', <br/> labelseparator:', // separator <br/> labelwidth: 50, // label width <br/> bodystyle: 'padding: 5 5 5 5', // form margin <br/> frame: false, <br/> Height: 150, <br/> width: 250, <br/> applyto: 'form', <br/> items: [<br/>{< br/> xtype: 'panel ', <br/> layout: 'column', // nested column layout <br/> border: false, // no border is displayed <br/> defaults: {// apply the configuration to each sub-element <br/> border: false, // do not display the border <br/> layout: 'form ', // nested form layout in column layout <br/> columnwidth :. 5 // column width <br/>}, <br/> items: [<br/>{< br/> labelseparator :':', // delimiter <br/> items: {<br/> xtype: 'radio', <br/> name: 'sex ', // a single region with the same name will act as a group <br/> fieldlabel: 'gender', <br/> boxlabel: 'male' <br/>}< br/> }, <br/> {<br/> items: {<br/> xtype: 'Radio ', <br/> name: 'sex ', // a single sequence with the same name will be used as a group <br/> hidelabel: True, // hide the label behind the horizontal layout <br/> boxlabel: female <br/>}< br/>] <br/>}, <br/>{< br/> xtype: 'panel ', <br/> layout: 'column', // nested column layout <br/> border: false, // no border is displayed <br/> defaults: {// apply the configuration to each sub-element <br/> border: false, // do not display the border <br/> layout: 'form ', // nested form layout in column layout <br/> columnwidth :. 5 // column width <br/>}, <br/> items: [<br/>{< br/> labelseparator :':', // delimiter <br/> items: {<br/> xtype: 'checkbox', <br/> name: 'swim ', <br/> fieldlabel: 'hobby ', <br/> boxlabel: 'swimming '<br/>}< br/>}, <br/>{< br/> items :{< br/> xtype: 'checkbox', <br/> name: 'walk ', <br/> hidelabel: True, // hide the label after horizontal layout <br/> boxlabel: 'Walking '<br/>}< br/>] <br/> })

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.