- Learning Ext JS(Fourth Edition)
- Carlos A. Méndez Crysfel Villa Armando Gonzalez
- 279字
- 2021-07-16 13:20:32
Comments about using layouts
Consider that you can nest layouts using combinations of containers and layouts, and also remember to ensure the right configuration each layout needs. In upcoming chapters, we will use layout nesting and containers-layout combinations so that you can have a more precise idea of how to combine these. Meanwhile, you can try to nest, combine, and play with the layout system.
One of the common mistakes that Ext JS beginners make is with the overnesting components; this can sometimes harm performance. You need to use layouts and set the proper type of container with adequate planning, for example:
Ext.onReady(function(){ Ext.create('Ext.panel.Panel', { width: 500, height: 300, title: 'Border Layout', layout: 'border', items: [ {// Incorrect Nesting xtype: 'panel', title: 'West Region', region:'west', width: 200, collapsible: true, layout: 'fit' items:[{ xtype: 'form', url: 'myForm.php' items[ // Fields here ] }] },{ title: 'Center Region', region: 'center', layout: 'fit', margin: '5 5 0 0', html:'<b>Main content</b> goes here' }], renderTo: Ext.getBody() }); });
As you can see, in the West region we are setting a panel that contains a form (Ext.form.Panel
). In this case, we are overnesting, because if you see the documentation, Ext.form.Panel
is extending a Panel
component and this will cause our browser to make more DOM. This can also reduce memory because we are creating two components instead of one; the right way should be:
{ xtype: 'form', title: 'West Region', region:'west', width: 200, collapsible: true, url: 'myForm.php' items[ // Fields here ] }
This way, the form panel acts the same way as any panel. We reduce one component with many properties, methods, and events that are not necessary and will only consume resources.
- 多媒體CAI課件設(shè)計(jì)與制作導(dǎo)論(第二版)
- Drupal 8 Blueprints
- Photoshop智能手機(jī)APP UI設(shè)計(jì)之道
- Windows系統(tǒng)管理與服務(wù)配置
- 機(jī)器人Python青少年編程開發(fā)實(shí)例
- PHP網(wǎng)絡(luò)編程學(xué)習(xí)筆記
- Learn Swift by Building Applications
- GeoServer Beginner's Guide(Second Edition)
- 編寫高質(zhì)量代碼:改善Objective-C程序的61個(gè)建議
- JavaWeb從入門到精通(視頻實(shí)戰(zhàn)版)
- Professional JavaScript
- Clojure編程樂趣
- 現(xiàn)代JavaScript編程:經(jīng)典范例與實(shí)踐技巧
- Instant AutoIt Scripting
- Java王者歸來:從入門邁向高手