简体   繁体   English

Extport中的Ext Grid定位或其他东西

[英]Ext Grid positioning in Viewport or something

Please suggest how can I position my grids on a single page. 请建议如何将我的网格放在一个页面上。 I am trying to place 3 Grid Panels in two rows with decent space between each grid.Panel. 我试图将3个网格面板放在两行中,每个网格之间有相当大的空间。面板。 I have three CRUD Grids populated with data from DB ( and it's store ): 我有三个CRUD网格填充了来自DB(和它的商店)的数据:

var UserGrid = Ext.create('Ext.grid.Panel', { ... }); var UserGrid = Ext.create('Ext.grid.Panel',{...});

var RoleGrid = Ext.create('Ext.grid.Panel', { ... }); var RoleGrid = Ext.create('Ext.grid.Panel',{...});

var Map = Ext.create('Ext.grid.Panel', { ... }); var Map = Ext.create('Ext.grid.Panel',{...});

Now I want to place them in different positions like I mentioned earlier. 现在我想把它们放在不同的位置,就像我之前提到的那样。 So, I want to be able to refer to my existing Grids in the Viewport or something. 所以,我希望能够在Viewport中引用我现有的网格或其他内容。

That is one part of my question. 这是我提问的一部分。 Also, I am really so annoyed by the ExtJS documentation on Sencha. 另外,我对Sencha的ExtJS文档非常恼火。 I know many people say it is elaborate. 我知道很多人都说它很精致。 I am very confused what configs or properties or methods I use in each Ext JS object. 我很困惑我在每个Ext JS对象中使用的配置或属性或方法。 The documentation does detail them, but I am not able to get hold of when to use what. 文档详细介绍了它们,但我无法掌握何时使用它们。 When do we use options given in 'config'? 我们什么时候使用'config'中给出的选项? When do we use options given in 'properties'. 我们什么时候使用'属性'中给出的选项。 When do we use options given in 'events'? 我们什么时候使用“事件”中给出的选项? More importantly how do we use them !! 更重要的是我们如何使用它们!!

You need to look how layout system works in ExtJs: http://docs.sencha.com/extjs/4.2.1/#!/guide/layouts_and_containers 您需要了解ExtJs中布局系统的工作原理: http ://docs.sencha.com/extjs/4.2.1/#!/guide/ layouts_and_containers

For your particular case I think you would need to configure viewport with border layout, put your first grid into center region, and create a container for other two grids in the south region. 对于您的特定情况,我认为您需要配置具有border布局的视口,将第一个网格放入center区域,并为south区域中的其他两个网格创建容器。

Also I'd recommend to specify what version of ExtJs you're using. 此外,我建议您指定您正在使用的ExtJ版本。

UPDATE: 更新:

So normally you would have somewhere in your viewport definition: 所以通常你会在视口定义中的某个地方:

layout: 'border'
items: [{
   xtype: 'panel', // This your UserGrid
   region: 'center',
   ... 
}, {
   xtype: 'container',
   region: 'south',
   layout: 'vbox',
   items: [{
      xtype: 'panel', // This your RoleGrid
      flex: 1
      ...
   }, {
      xtype: 'panel', // This your Map
      flex: 1
      ...
   }]
   ... 
}]

This will be true if you don't have special variables for grid (ie if you will not create them manually but let ExtJs create them for you. 如果您没有网格的特殊变量(例如,如果您不手动创建它们但让ExtJ为您创建它们),则会出现这种情况。

Now, if you have any special logic or configuration inside these grids, then you might define your own classes and inherit them from standard panel/grid. 现在,如果这些网格中有任何特殊的逻辑或配置,那么您可以定义自己的类并从标准面板/网格继承它们。 In this case you obviously change xtype: 'panel' in the code above with proper xtype for your class. 在这种情况下,您显然会在上面的代码中使用适当的xtype更改xtype: 'panel'

If you want to create grids beforehand (there are might be some reason for that, but I rarely do so) you would need to pass region configuration to your first grid when creating it: 如果你想事先创建网格(可能有一些原因,但我很少这样做),你需要在创建它时将region配置传递给你的第一个网格:

var UserGrid =  Ext.create('Ext.grid.Panel', {
   region: 'center',
   ... 
}); 

And then change the viewport code to something like this: 然后将视口代码更改为以下内容:

layout: 'border'
items: [userGrid, {
   xtype: 'container',
   region: 'south',
   layout: 'vbox',
   items: [RoleGrid, Map]
   ... 
}]

As already said, you have to learn to uses the different layouts. 如前所述,您必须学会使用不同的布局。 See this demo to get an idea of what's available. 请参阅此演示以了解可用的内容。

Now, regarding the structure of the doc, 'configs', 'methods', 'properties', and 'events' are really three different concepts, but only config is specific to Ext. 现在,关于doc的结构,'configs','methods','properties'和'events'实际上是三个不同的概念,但只有config特定于Ext。 The others are general object oriented concepts. 其他是一般面向对象的概念。

In a nutshell: 简而言之:

  • Properties are the variables that are bound to on object. 属性是绑定到对象的变量。 In the context of Ext, they are almost always read-only. 在Ext的上下文中,它们几乎总是只读的。 That don't means that you can't change their value (impossible to prevent in Javascript), but that you shouldn't . 这并不意味着你无法改变它们的价值(在Javascript中无法阻止),但你不应该这样做 So you use poperties to read information from existing objects. 因此,您使用poperties从现有对象中读取信息。 For example: 例如:

     if (checkbox.checked) { ... } 
  • Config options are the option that you can use when you create an object. 配置选项是您在创建对象时可以使用的选项。 Almost all constructors in Ext accept one single argument, an object called the config object. Ext中的几乎所有构造函数都接受一个参数,一个名为config对象的对象。 So you use config options when you create an object: 因此,在创建对象时使用配置选项:

     Ext.create('Ext.window.Window', { width: 200, height: 200, ... }); 
  • Methods is the name given to functions that belongs to an object. 方法是属于对象的函数的名称。 Unlike properties, when you use a method, code is running, so that's what you use for doing things. 与属性不同,当您使用方法时,代码正在运行,因此您使用的是用于执行操作的内容。

     window.show(); // using the animate parameter window.show(true); 
  • Events are things that happen in the application. 事件是应用程序中发生的事情。 You can react to them by attaching listeners (also named callback functions) to them. 您可以通过将侦听器 (也称为回调函数) 附加到它们来对它们做出反应。 The parameters that are given for events in the doc are the one that will be passed your callback method. 为doc中的事件指定的参数是将传递回调方法的参数。

     // Eg displaying an alert when a button is clicked button.addListener( // name of the event 'click', // the callback function function() { alert('Clicked!'); } ) 

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

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