Ext-GWT / GXT(不是)简单的布局问题? [英] Ext-GWT / GXT (Not So) Simple Layout Issue?

查看:92
本文介绍了Ext-GWT / GXT(不是)简单的布局问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ext-GWT论坛上发布了这个问题,我只是希望这里的某个人可能会为我提供一个答案!



我正在努力做一些事情我最初认为很简单,但我开始相信是不可能的......



我有各种各样的布局模板 - 只包含几个GWT DockLayoutPanel其他并最终以LayoutPanels结尾。 GWT的LayoutPanel被设计用于调整添加到它的完整大小的小部件(或复合),并且与纯GWT小部件完美匹配。



我的布局模板是我不知道内部LayoutPanel的EXACT高度和宽度,因为我可以在实例化此模板时以不同方式设置某些面板大小(外部DockLayoutPanels)。我希望将一个Grid组件添加到最内层的LayoutPanel中,并使其自身的大小(高度和宽度)与普通的GWT小部件一样大小(例如与GWT标签完美匹配)。



我对GXT非常陌生(就像我今天早些时候开始使用它),我意识到GXT根据GWT在DOM上构建它的Widget的方式不同地构建其组件。



有没有办法达到预期的结果?我曾尝试将网格添加到具有FitLayout布局的ContentPanel,我尝试过AnchorLayout,我尝试过直接添加网格...没有任何工作似乎...任何建议,甚至是在正确的方向推动将大大感谢!



感谢提前!

Xandel

解决方案

只是在这篇文章和我已采取的方向笔记。当我开始我的GWT项目,并且我正在学习基础知识并阅读其他人的帖子,关注和建议时,我最初忽略的一点建议非常简单 - 当使用GWT框架时,仅使用纯粹的100%GWT组件。



我最初忽略了开发人员的这些公正警告,因为在开源工具和开源项目的时代,人们开发了一套思想集合,而不是构建一个工具,我有一定的功能,让我看看别人是否已经做到了。这种思维模式加快了开发速度,几乎实现了项目和实施方法的标准化。然而,我发现在过去的两个月里,在使用GWT时最好不要遵循这个原则。也许是因为它没有像其他框架那样广泛传播,或者需要一种非常特定的编码风格,但是我对搜索(简单,可排序,JSON可加载)网格组件和(验证,整齐风格)表单组件没有任何帮助短暂的噩梦。



这并不是因为它们不存在。他们是这样。我试过ext-gwt,gwt-ext,gwt-mosaic和gwt-incubator。这是因为很多组件都脱离了GWT提供的非常简单的布局基础(换句话说,您放置窗口小部件的面板大多需要是随工具一起提供的面板)。这反过来又使混合成分和获得理想的结果几乎不可能。这反过来又摆脱了让我发现一个有用的组件心态。



只是我认为值得一提的一个有趣和最后的观点。所以,由于我对上述观点的认识,我着手编写自己的网格和表单组件。我已经完成并且对我工作得很好(显然,因为我写了他们,我不认为他们会对其他人有用)。但是在编写网格组件的过程中,需要列自动调整大小并在其父面板中绘制空间时,我发现直到最终绘制才知道面板的最终宽度(这种情况很长时间才会发生你的代码执行)。具有讽刺意味的是,我开始着手构建一组面板,这些面板从父面板(最终需要了解其大小)直到最内面的面板,从而当我的网格组件最终绘制完成时,我可以相互通信发射一个名为onSizeKnown(int width,int height)的方法并做任何需要的尺寸。



完成这个之后,我只能笑出声来。因为突然间我明白为什么所有其他GWT组件都需要自己的面板。我基本上也必须这样做才能得到我需要的工作。

所以简而言之,如果你是像我一样的新手GWT开发人员并且(是?)寻找很酷的东西,让你的项目看起来很棒 - 这是我的建议 - 如果你打算使用外部框架,比如上面提到的一些框架 - 只使用那个框架。不要将其组件与其他框架混用。学会爱这个框架,并使用他们的面板和设计方法从底层开始构建您的项目。如果这让你感到恐慌,并让你感到紧张和有限,那么请做我所做的并使用纯香草GWT组件编写自己的。您可以按照这个建议节省很多时间。



Xandel


I have posted this question on the Ext-GWT forums, I am just hoping that someone here might have an answer for me!

I am struggling to do something I initially thought was simple but am beginning to believe is impossible...

I have got a "layout template" of sorts - simply consisting of a few GWT DockLayoutPanel's within each other and finally ending in LayoutPanels. GWT's LayoutPanel is designed to size the widget (or Composite) that's added to it to its full size and does so perfectly with pure GWT widgets.

The idea of my "layout template" is that I don't know the EXACT height and width of the very inner LayoutPanel's because I may set certain panels sizes (of the outer DockLayoutPanels) differently when instantiating this template. All I would like is to add a Grid component to one of the inner most LayoutPanels and have it size itself (height AND width) to fit as normal GWT widgets do (works perfectly with a GWT Label for instance).

I am VERY new to GXT (as in I started using it earlier today) and I do realize that GXT builds its Components differently to the way GWT builds its Widgets on the DOM.

Is there anyway to achieve the desired result? I have tried adding the grid to a ContentPanel with a Layout of FitLayout, I have tried AnchorLayout, I have tried adding the grid directly... Nothing seems to work... Any advice or even a push in the right direction would be greatly appreciated!

Thanks in advance!

Xandel

解决方案

Just a note on this post and the direction I have taken. When I started my GWT project and I was learning the basics and reading through others posts and concerns and advice, the one bit of advice I overlooked initially was quite simple - when using the GWT framework use pure 100% GWT components only.

I initially ignored these fair warnings of fellow developers because in the age of open source tools, and open source projects, one develops the mind set of "Instead of building a tool which will give me certain functionality, let me rather see if someone else has done it already". This mindset speeds up development and almost standardizes projects and methods of implementation.

However, I have found over the last two months, that when working with GWT it is best to not follow this principle. Maybe because its not as widely spread as other frameworks, or demands a very certain type of coding style but non the less my search for a (simple, sortable, JSON loadable) grid component and (validating, neatly styled) form component has been nothing short of a nightmare.

This isn't because they don't exist. They do. I tried ext-gwt, gwt-ext, gwt-mosaic, and gwt-incubator. It is because many of the components break away from the very simple layout foundation that GWT provides (in other words, the panels that you place the widgets on mostly need to be the panels provided with the tools). This in turn makes mixing components and getting the desired result near impossible. Which in turn breaks away from the let-me-find-a-useful-component mindset.

Just an interesting and final point which I think might be worth mentioning. So due to my realisation of the above mentioned point, I set about to write my own grid and form components. Which I have completed and are working fine for me (obviously, because I wrote them , I don't suspect they will be useful to everybody else). But in the process of writing the grid component, and needing the columns to size and space themselves out automatically once drawn in their parent panel, I found that knowledge of the panels final width is not known until finally being drawn (this happens long after all your code executes). So ironically I set about building a set of panels that communicate to each other, from the parent panel (who ultimately NEEDS to have knowledge of its size) right down to the most inner panels so that when my grid component finally gets drawn, I can fire a method called onSizeKnown(int width, int height) and do whatever sizing is required.

After I completed this I could do nothing but laugh. Because it suddenly became clear to me why all the other GWT components out there require their own panels. I in essence had to do the same to get what I needed working.

So in short, if you are a newbie GWT developer like I was and are (is?) looking for cool stuff to make your project look awesome - this is my advice - if you are going to use an external framework such as some of the above mentioned - use ONLY that framework. Do not mix its components with other frameworks. Learn to love that framework, and build your project from the bottom up using their panels and design methods. If this scares you and makes you feel nervous and limited then do what I did and write your own using pure vanilla GWT components. You will save yourself A LOT of time in the long run by following this advice.

Xandel

这篇关于Ext-GWT / GXT(不是)简单的布局问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆