In the desktop demo in ExtJS, the default icons are arranged without line breaks. The following code is used to solve this problem. If you need to know about the desktop demo in ExtJS, by default, icons are arranged without line breaks, which causes too many icons on the desktop to overlay the desktop area, 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.
The 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.
The 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.
The 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 );
}