GWT Flex 表问题

发布于 2024-10-13 04:53:47 字数 5278 浏览 4 评论 0 原文

我正在使用以下代码动态创建一个弹性表。

for (int CurrentRow=1;CurrentRow<2;CurrentRow++)
                {
                    Label lblGettingName = new Label("Getting Name...");
                    View.getMainFlex().setWidget(CurrentRow, 0, lblGettingName);

                    Button btnViewDetails = new Button("View Details");
                    View.getMainFlex().setWidget(CurrentRow, 1, btnViewDetails);

                    Label lblGettingBid = new Label("Getting Bid...");
                    View.getMainFlex().setWidget(CurrentRow, 2, lblGettingBid);
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 2, "BackNormalNotBold");

                    Label lblGettingBidDesription = new Label("Getting Bid Desription...");
                    lblGettingBidDesription.setStyleName("BidDesc");
                    View.getMainFlex().setWidget(CurrentRow, 3, lblGettingBidDesription);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow, 3, "40");
                    View.getMainFlex().getFlexCellFormatter().setStylePrimaryName(CurrentRow, 3, ".BidDesc");

                    Label lblCalculating = new Label("Calculating..");

                    Label lblCalculatingTime = new Label("Calculating Time...");
                    View.getMainFlex().setWidget(CurrentRow, 4, lblCalculatingTime);
                    View.getMainFlex().getFlexCellFormatter().setStyleName(1,4, "BackNormalNotBold");

                    TextBox textBox = new TextBox();
                    View.getMainFlex().setWidget(CurrentRow+1, 3, textBox);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow+1, 3, "40");

                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 0, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 1, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 2, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow+1, 3, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 4, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 2, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 1, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 0, 3);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow+1, 3, 2);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow, 3, 2);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow-1, 3, 2);

                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 1, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setVerticalAlignment(CurrentRow, 1, HasVerticalAlignment.ALIGN_MIDDLE);
                    View.getMainFlex().getCellFormatter().setVerticalAlignment(CurrentRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow+1, 3, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 3, HasHorizontalAlignment.ALIGN_CENTER);

                    Button btnPlaceBid = new Button("Bid!");
                    View.getMainFlex().setWidget(CurrentRow+2, 3, btnPlaceBid);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow+2, 3, "20");
                    btnPlaceBid.setSize("66px", "26px");

                    ToggleButton tglbtnAutomate = new ToggleButton("Automate");
                    View.getMainFlex().setWidget(3, 4, tglbtnAutomate);
                    View.getMainFlex().getCellFormatter().setWidth(3, 4, "20");
                    tglbtnAutomate.getDownHoveringFace().setText("TurnOFF");
                    tglbtnAutomate.getUpHoveringFace().setText("TurnON");
                    tglbtnAutomate.getDownDisabledFace().setText("Enable");
                    tglbtnAutomate.setHTML("Auto:OFF");
                    tglbtnAutomate.getUpFace().setHTML("Auto:OFF");
                    tglbtnAutomate.getDownFace().setHTML("Auto:ON");
                    tglbtnAutomate.setSize("54px", "18px");
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow+2, 3, HasHorizontalAlignment.ALIGN_RIGHT);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow-1, 4, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 4, HasHorizontalAlignment.ALIGN_CENTER);
                }
                FlexTableHelper.fixRowSpan(View.getMainFlex());

当循环仅执行一次时,会生成正确的布局,但是当我尝试创建多于 1 行时,布局会退化

I am creating a flex table dynamically with the following code.

for (int CurrentRow=1;CurrentRow<2;CurrentRow++)
                {
                    Label lblGettingName = new Label("Getting Name...");
                    View.getMainFlex().setWidget(CurrentRow, 0, lblGettingName);

                    Button btnViewDetails = new Button("View Details");
                    View.getMainFlex().setWidget(CurrentRow, 1, btnViewDetails);

                    Label lblGettingBid = new Label("Getting Bid...");
                    View.getMainFlex().setWidget(CurrentRow, 2, lblGettingBid);
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 2, "BackNormalNotBold");

                    Label lblGettingBidDesription = new Label("Getting Bid Desription...");
                    lblGettingBidDesription.setStyleName("BidDesc");
                    View.getMainFlex().setWidget(CurrentRow, 3, lblGettingBidDesription);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow, 3, "40");
                    View.getMainFlex().getFlexCellFormatter().setStylePrimaryName(CurrentRow, 3, ".BidDesc");

                    Label lblCalculating = new Label("Calculating..");

                    Label lblCalculatingTime = new Label("Calculating Time...");
                    View.getMainFlex().setWidget(CurrentRow, 4, lblCalculatingTime);
                    View.getMainFlex().getFlexCellFormatter().setStyleName(1,4, "BackNormalNotBold");

                    TextBox textBox = new TextBox();
                    View.getMainFlex().setWidget(CurrentRow+1, 3, textBox);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow+1, 3, "40");

                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 0, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 1, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow, 2, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setStyleName(CurrentRow+1, 3, "BackNormalNotBold");
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 4, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 2, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 1, 3);
                    View.getMainFlex().getFlexCellFormatter().setRowSpan(CurrentRow, 0, 3);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow+1, 3, 2);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow, 3, 2);
                    View.getMainFlex().getFlexCellFormatter().setColSpan(CurrentRow-1, 3, 2);

                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 1, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setVerticalAlignment(CurrentRow, 1, HasVerticalAlignment.ALIGN_MIDDLE);
                    View.getMainFlex().getCellFormatter().setVerticalAlignment(CurrentRow, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 2, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow+1, 3, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 3, HasHorizontalAlignment.ALIGN_CENTER);

                    Button btnPlaceBid = new Button("Bid!");
                    View.getMainFlex().setWidget(CurrentRow+2, 3, btnPlaceBid);
                    View.getMainFlex().getCellFormatter().setWidth(CurrentRow+2, 3, "20");
                    btnPlaceBid.setSize("66px", "26px");

                    ToggleButton tglbtnAutomate = new ToggleButton("Automate");
                    View.getMainFlex().setWidget(3, 4, tglbtnAutomate);
                    View.getMainFlex().getCellFormatter().setWidth(3, 4, "20");
                    tglbtnAutomate.getDownHoveringFace().setText("TurnOFF");
                    tglbtnAutomate.getUpHoveringFace().setText("TurnON");
                    tglbtnAutomate.getDownDisabledFace().setText("Enable");
                    tglbtnAutomate.setHTML("Auto:OFF");
                    tglbtnAutomate.getUpFace().setHTML("Auto:OFF");
                    tglbtnAutomate.getDownFace().setHTML("Auto:ON");
                    tglbtnAutomate.setSize("54px", "18px");
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow+2, 3, HasHorizontalAlignment.ALIGN_RIGHT);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow-1, 4, HasHorizontalAlignment.ALIGN_CENTER);
                    View.getMainFlex().getCellFormatter().setHorizontalAlignment(CurrentRow, 4, HasHorizontalAlignment.ALIGN_CENTER);
                }
                FlexTableHelper.fixRowSpan(View.getMainFlex());

When the loop executes only once, the correct layout is generated but when i try to create more than 1 row, the layout degerate

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

就此别过 2024-10-20 04:53:47

Flextable 最有可能出现的问题是由 setRowSpan/setColSpan 方法引起的,这些方法很容易对布局造成严重破坏。您可以创建复合小部件/Html 并将其放置在单元格中,而不是使用这些方法,这样 Flextable 的行/列数量就会减少。

Most likely problems with flextable are caused by setRowSpan/setColSpan methods which can easily wreak havoc in layout. Instead of using those methods you can create composite widget/Html and place it in cells so Flextable will have less amount of rows/columns.

以往的大感动 2024-10-20 04:53:47

FlexTable 使用 td 的旧元素属性,如宽度、高度、对齐等。
即使在最新版本中,它也尚未适应使用 CSS。 IE11 不再支持 例如,根本没有。

FlexTable uses old element attributes of td like width, height, align etc.
It is not yet adapted to use CSS instead even in the newest release. IE11 does no longer support <td align="..."> at all, for example.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文