1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    2
    Vote Rating
    0
    Xandrios is on a distinguished road

      0  

    Default ALIGN_RIGHT and JS errors

    ALIGN_RIGHT and JS errors


    Hi,

    I am trying to add a button, label and button to a HorizontalPanel. In such way that the label is centered and the last button right-aligned.

    Code:
    HorizontalPanel footerPanel  = new HorizontalPanel();
    footerPanel.setWidth("100%");
    footerPanel.add(prevButton);
    footerPanel.setCellHorizontalAlignment(prevButton, HasHorizontalAlignment.ALIGN_LEFT);
    footerPanel.add(pagenumLabel);
    footerPanel.setCellHorizontalAlignment(pagenumLabel, HasHorizontalAlignment.ALIGN_CENTER);
    footerPanel.add(nextButton);
    footerPanel.setCellHorizontalAlignment(nextButton, HasHorizontalAlignment.ALIGN_RIGHT);
    This has always worked well with GWT and GWT-EXT. With GXT however it compiles cleanly but spits out an error at runtime:

    Code:
    com.google.gwt.core.client.JavaScriptException: (TypeError): 'children' is null or not an object
     number: -2146823281
     description: 'children' is null or not an object
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:443)
    When I try to use a GXT HorizontalPanel it is supposed to work like this:

    Code:
    footerPanel.add(prevButton, new TableData("left", "middle"));
    footerPanel.add(pagenumLabel, new TableData("center", "middle"));
    footerPanel.add(nextButton, new TableData("right", "middle"));
    Which compiles cleanly as well, however at runtime:
    Code:
    com.google.gwt.core.client.JavaScriptException: (Error): Invalid argument.
     number: -2147024809
     description: Invalid argument.
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:443)
    Which seems to be roughly the same error.

    Am I doing something wrong? Am I supposed to do alignment another way? Or could it be a bug?

    On this board I found one other thread about this issue, which was not resolved.

    Thanks!

  2. #2
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    If you include complete test code I will take a look at your use with a GWT HorizontalPanel.

    Code:
    new TableData("left", "middle"));
    This constructor expects widths not alignment. You need to use the alignment constants.

  3. #3
    Ext User
    Join Date
    Jul 2008
    Posts
    2
    Vote Rating
    0
    Xandrios is on a distinguished road

      0  

    Default


    Thanks

    That seems to be a mistake in the Javadoc Api then, this is pretty much a copy/paste from the TableData example. Even with the Style.HorizontalAlignment it does not work however - doesnt spawn any errors but does not align either.

    Basically the code is as follows:
    Code:
        private Panel tablePanel;
        private FlexTable table;
        private HorizontalPanel footerPanel;
        private int cols = 0;
        private TableElement tableElement;
    
    [..]
    
    public DynamicTable(GWF gwf, TableElement tableElement) {
            this.gwf = gwf;
            this.tableElement = tableElement;
            this.recordsPerPage = tableElement.getItemsPerPage();
    
            // table
            tablePanel = new ContentPanel();
            tablePanel.setHeading(tableElement.getTableTitle());
            table = new FlexTable();
            tablePanel.add(table);
    
            // spacer
            HorizontalPanel spacer = new HorizontalPanel();
            spacer.add(new Label(" "));
            spacer.setHeight("25px");
            tablePanel.add(spacer);
    
            // footer
            footerPanel = new HorizontalPanel();
            footerPanel.setWidth("100%");                        
            
            footerPanel.add(prevButton);
            footerPanel.setCellHorizontalAlignment(prevButton, HasHorizontalAlignment.ALIGN_LEFT);
            footerPanel.add(pagenumLabel);
            footerPanel.setCellHorizontalAlignment(pagenumLabel, HasHorizontalAlignment.ALIGN_CENTER);
            footerPanel.add(nextButton);
            footerPanel.setCellHorizontalAlignment(nextButton, HasHorizontalAlignment.ALIGN_RIGHT);
                    
            tablePanel.add(footerPanel);
            table.setWidth("100%");
     
            this.setHeaders(tableElement.getColumnNames());
            
            this.renderToolbar();
    
            initWidget(tablePanel);
    
            this.requestData();
        }
    
    [..]
    Thanks

  4. #4
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    4
    gslender is on a distinguished road

      0  

    Default


    post code using these guidelines http://extjs.com/forum/showthread.php?t=33778

Thread Participants: 2