2011-01-19 2 views
0

Je crée dynamiquement une table flexible avec le code suivant.GWT Flex Table Problème

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

Lorsque la boucle exécute une seule fois, la mise en page correcte est générée mais lorsque je tente de créer plus de 1 ligne, la mise en page degerate

Répondre

0

Les problèmes les plus probables avec flextable sont causées par setRowSpan/setColSpan méthodes peut facilement faire des ravages dans la mise en page. Au lieu d'utiliser ces méthodes, vous pouvez créer un widget composite/Html et le placer dans des cellules pour que Flextable ait moins de lignes/colonnes.

0

FlexTable utilise les anciens attributs d'élément tels que la largeur, la hauteur, l'alignement, etc. Il n'est pas encore adapté pour utiliser CSS, même dans la version la plus récente. IE11 ne prend plus en charge < td align = "..." > du tout, par exemple.