ExtJS [Desktop] implements a line feed sample code

Source: Internet
Author: User

In the desktop demo in ExtJS, the default icons are arranged without line breaks, which causes the icons to be overwritten if there are too many icons on the desktop, that is, the part that exceeds the desktop area will be blocked by the taskbar. The following code is used to solve this problem.

First, expand a function in desktop. js.
Copy codeThe Code is as follows:
InitShortcut: function (){
Var btnHeight = 64;
Var btnWidth = 64;
Var btnPadding = 30;
Var col = {index: 1, x: btnPadding };
Var row = {index: 1, y: btnPadding };
Var bottom;
Var numberOfItems = 0;
Var taskBarHeight = Ext. query (". ux-taskbar") [0]. clientHeight + 40;
Var bodyHeight = Ext. getBody (). getHeight ()-taskBarHeight;
Var items = Ext. query (". ux-desktop-shortcut cut ");

For (var I = 0, len = items. length; I <len; I ++ ){
NumberOfItems + = 1;
Bottom = row. y + btnHeight;
If (bodyHeight <bottom )? True: false) & bottom> (btnHeight + btnPadding )){
NumberOfItems = 0;
Col = {index: col. index ++, x: col. x + btnWidth + btnPadding };
Row = {index: 1, y: btnPadding };
}
Ext. fly (items [I]). setXY ([col. x, row. y]);
Row. index ++;
Row. y = row. y + btnHeight + btnPadding;
}
}

Add a listener in the createDataView method of the current js file.
Copy codeThe Code is as follows:
CreateDataView: function (){
Var me = this;
Return {
Xtype: 'dataview ',
OverItemCls: 'x-view-over ',
TrackOver: true,
ItemSelector: me. me cutitemselector,
Store: me. shortcuts,
Tpl: new Ext. XTemplate (me. shortcutTpl ),
Listeners :{
Resize: me. initShortcut
}
};
}

Furthermore, the function is called at the end of the afterRender rendering.
Copy codeThe Code is as follows:
AfterRender: function (){
Var me = this;
Me. callParent ();
Me. el. on ('textmenu ', me. on1_topmenu, me );
Ext. Function. defer (me. initShortcut, 1 );
}

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.