In the use of Ext development app, the general framework is the left side of the menu bar, the middle of the tab-style display area. The tab page is mostly embedded with an IFRAME to display the content. However, the use of IFRAME has a big drawback is that each time the load a new IFRAME will be the core of ext js,css file reload. Because ext is a huge class library, the volume of these files are very large, just ext-all.js has more than 400 K, so the use of an IFRAME loaded to reduce the efficiency greatly. In order to solve this problem, I recommend using the Ext.panel autoload mode to load the page. Loading with this mode can avoid the problem of the EXT core file reloading. Can improve the operation efficiency of the program very well. Here's a brief introduction to the process and principles of implementation, as well as the problems I have encountered in development and how to solve these problems.
Several technical points of this pattern are
1. Click on the menu event implementation.
2. How to write the page that will be loaded.
3. How to get the height and width of the control that loads the page to adapt, such as Panel,grid.
Implementation of menu Events
This function requires three parameters,
A. Module number, this number is custom, do not and must be unique. In the menu click event to pass this number over, as the tab page ID
B. The URL of the module's Url,tab sub-page AutoLoad
C. The name of the module, title of the tab sub page
The code is as follows:
function AddTab (id,link,name) {
var tabid = "tab-" +ID; Modify the ID slightly.
var tabtitle = name;
var tablink = link;
var centerpanel = ext.getcmp (' Displaycenterpanel ');
var tab = centerpanel.getcomponent (tabid);//Get Tab Build
The height and width of the controls that load the page are adaptive
Because this type of page loaded with AutoLoad mode does not change with the size of the browser. So we want to implement the browser's size change function, that is, the Window.onresize event.
But in the implementation of this event, we must add settimeout to control it, let it delay the implementation of a moment, otherwise it can not achieve our results.
A function that controls the size of the tab page container
function Allcomresize () {
var Modelidarr = Modelids.split (",");
var len = modelidarr.length;
if (len==0) {
return false;
}
var w = ext.getcmp (' Displaycenterpanel '). Getactivetab (). Getinnerwidth ();
var h = ext.getcmp (' Displaycenterpanel '). Getactivetab (). Getinnerheight ();
for (var i=0; i<len;i++) {
var tmpmodelid = Modelidarr;
var subpage = ext.getcmp ("tab-" +tmpmodelid+ "-main");
if (subpage) {
Subpage.setwidth (w);
Subpage.setheight (h);
}
}
}
To perform allcomresize functions by window.onresize Events to control the tab container's size
var otime;
Window.onresize = function ()
{
if (otime)
{
Cleartimeout (Otime);
}
Otime = settimeout ("Allcomresize ()", 100); Delayed 100 millisecond execution
}
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.