简体   繁体   English

如何在Ext js面板中分别在面板的顶部和左侧添加高度和宽度?

[英]How can I add height and Width on Top and Left side of a Panel respectively in Ext js panel?

I have created a TabPanel in Ext js 4.0. 我已经在Ext js 4.0中创建了一个TabPanel。

I add some grids dynamically to the panel. 我向面板动态添加了一些网格。 The size of the panel increases when the number of grids increase. 当网格数量增加时,面板的尺寸也会增加。

Below are the screenshot to represent it: 以下是表示它的屏幕截图:

Panel with Single Grid: 单格面板: 在此处输入图片说明

In the above picture I have added single grid. 在上图中,我添加了单个网格。 Now I will add few more grids to the same below the existing grid as follows: 现在,我将在现有网格下面的网格中再添加几个网格,如下所示:

Panel with Multiple Grid: 具有多个网格的面板: 在此处输入图片说明

As you can see in the second picture the height of the panel is increased and a scrollbar has come up on right side of the panel. 如您在第二张图片中所见,面板的高度增加了,并且面板右侧出现了滚动条。

Now in the above example the height of the panel is increasing from the bottom of the panel. 现在在上面的示例中,面板的高度从面板的底部开始增加。 But I want to add grids on top of the first grid and increase the height on top side of the panel. 但是我想在第一个网格的顶部添加网格,并在面板的顶部增加高度。

Similarly I want to increase width on left side of panel. 同样,我想增加面板左侧的宽度。 How can this be done? 如何才能做到这一点?

I don't want to add the grid at top and move all the other grids to the bottom because there are large number of grids present in the panel which are arranged relative to each other. 我不想在顶部添加网格并将所有其他网格移到底部,因为面板中存在大量相对于彼此排列的网格。

This can't be done as you would like it to, because the reference point in ExtJS and plain JavaScript and HTML always is the top left, which is (0,0). 这无法按您的意愿进行,因为ExtJS和普通JavaScript和HTML中的参考点始终位于左上角,即(0,0)。

If you want to add a grid above the other grids, you have to use container.insert(0,component) , thereby changing the position of all the other grids. 如果要在其他网格上方添加网格,则必须使用container.insert(0,component) ,从而更改所有其他网格的位置。 You can then scrollTo the bottom. 然后,您可以scrollTo到底部。

You can set add manually grids on panel at first position like : 您可以在面板的第一个位置设置手动添加网格,例如:

var Mypanel = Ext.ComponentQuery.query('#mypanel')[0]; var Mypanel = Ext.ComponentQuery.query('#mypanel')[0];

Mypanel.insert(0,cmp1); Mypanel.insert(0,cmp1);

Even you can set manually position of scrollbar at top by using below example. 您甚至可以通过以下示例手动设置滚动条的顶部位置。 scrollbar position on adding each 添加每个滚动条时的位置

scrollPos = Mypanel.getEl().down('.x-grid-view').getScroll().top; scrollPos = Mypanel.getEl()。down('。x-grid-view')。getScroll()。top;

To set dynamically scrollPos : Mypanel.getEl().down('.x-grid-view').scrollTo('top',scrollPos,true); 动态设置scrollPos: Mypanel.getEl()。down('。x-grid-view')。scrollTo('top',scrollPos,true);

To set scrollPos at top position : Mypanel.getEl().down('.x-grid-view').scrollTo('top',0,true); 要将scrollPos设置在顶部位置: Mypanel.getEl()。down('。x-grid-view')。scrollTo('top',0,true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM