Pregunta

Estoy creando una tabla de flexión dinámica con el siguiente código.

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());

Cuando el bucle se ejecuta sólo una vez, se genera el diseño correcto pero cuando intento para crear más de 1 fila, la disposición degerate

¿Fue útil?

Solución

La mayoría de los problemas probables con FlexTable son causadas por métodos setRowSpan / setColSpan estragos que puede fácilmente estragos en la disposición. En lugar de utilizar los métodos que puede crear el compuesto Reproductor / HTML y colocarlo en las células de modo FlexTable tendrá menos cantidad de filas / columnas.

Otros consejos

FlexTable utiliza atributos elemento antiguo de td como anchura, altura, align etc. Todavía no está adaptado para utilizar CSS en lugar incluso en la versión más reciente. EI11 hace no más de apoyo en absoluto, por ejemplo.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top