Wednesday, March 9, 2016

How to use DataGrid?

I'd been trying to use the DataGrid but I am running into problems. Consider this code.

private static class MyWidget extends Composite {
   
    private SimpleLayoutPanel slp = new SimpleLayoutPanel ();
    private VerticalPanel vPanel = new VerticalPanel();
    private SimplePager pager = new SimplePager ();
    private DataGrid<Caption> table = new DataGrid<Foo> (5);
 
   
    ListDataProvider<Caption> dataProvider = new ListDataProvider<Foo>();

public    MyWidget (){
       
        initWidget (vPanel);
           
        dataProvider.addDataDisplay (table);
        dataProvider.setList (FOO);
       
      
       
        pager.setDisplay (table);
       
     
        slp.add (table);
            
        vPanel.add (slp);
        vPanel.add (pager);
               
 
        pager.setVisible (true);
        table.setVisible (true);
     
               
        table.setKeyboardSelectionPolicy (KeyboardSelectionPolicy.ENABLED);
       
        TextColumn<Foo> captionLine = new TextColumn<Foo>(){
        @Override
        public String getValue (Caption object){
            return object.line ;
           
        }
        };



       
        table.setRowCount(CAPTION.size(), true);
     
        table.setRowData(0, CAPTION);
        table.setWidth ("100%");
   
        }

When I run the code and test it, I do not see the DataGrid on the table just the pager. If I do something like

 slp.add(tablet);
  RootLayoutPanel.get().add(slp);
      RootLayoutPanel.get().add(pager);

I can see the contents on the table and the pager on top of DataGrid.

regards
anne

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment