PDA

View Full Version : Issue with Grid Data



atlanta.peter
4 Nov 2011, 11:51 AM
I have a Grid in Accordian Layout.

The Grid Cloumns are being displayed but the row data is not being diplayed.

But again I have a event Listener added to the grid. and the event is working perfectly fine. I am able to get the Selected Model data from the event Object and pass it to the next Widget.

Has someone experienced a similar problem. Appreciate any help

sven
4 Nov 2011, 11:52 AM
Have you tried to reproduce this in a small standalone testcase?

Are you sure that the grid does not contain any data or is it just not visible? You can check that easily with firebug

atlanta.peter
4 Nov 2011, 12:03 PM
I havent checked it in firbug. But I am sure it is present in the grid and just not visible.

I am saying that because the same data is being passed to the Event. But will check it in firebug anyways

Do you have any idea how to make the data visible. I tried setting all kinds of sizes for both the ContentPanel and the Grid . Which dint work ofcourse

sven
4 Nov 2011, 12:10 PM
Can you verify the height of your grid? Sounds like you have not set any height on it or the parent and so it fails to display

atlanta.peter
5 Nov 2011, 5:41 PM
Sven,

I am sorry for being so sure abt the grid containing data. Turns our my Grid does not contain any data, but as weird as it gets the grind event works fine.

Ok getting back to my concern , I realised that I missed out mentioning a very imp point.
Actually I am using uibinder GXT Grid.

So I went back and tried a sample first ( a simple test) just to make sure , and the sample also did not work for me. So my question is does the uibinder GXT Grid work at all.
I did use Form and other panels in uibinder GXT which worked great for me. I am stuck with the Grid.

atlanta.peter
5 Nov 2011, 10:05 PM
LayoutContainer c = new LayoutContainer();
private ColumnModel cm;
public SearchResultsViewImpl() {
createView();
initComponent(c);
}
private Presenter presenter;


public void setPresenter(Presenter presenter) {
this.presenter = presenter;
}


public void createView(){




c.setLayout(new FlowLayout(10));

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("id");
column.setHeader("id");
column.setWidth(200);
configs.add(column);

column = new ColumnConfig();
column.setId("firstName");
column.setHeader("firstName");
column.setWidth(100);
configs.add(column);

ListStore<PersonDTO> store = new ListStore<PersonDTO>();
store.add(new PersonDTO(new Integer(0),"test","test","test","test","test","test","test","test","test",
new Integer(0),new Date(),new Integer(0),new Date(),"test","test","test","test","test","test","test"));

cm = new ColumnModel(configs);

ContentPanel cp = new ContentPanel();
cp.setBodyBorder(true);
cp.setHeading("Basic Grid");
cp.setLayout(new FitLayout());
cp.getHeader().setIconAltText("Grid Icon");
cp.setSize(600, 300);

final Grid<PersonDTO> grid = new Grid<PersonDTO>(store, cm);
grid.setStyleAttribute("borderTop", "none");
grid.setBorders(false);
grid.setStripeRows(true);
grid.setColumnLines(true);
grid.setColumnReordering(true);
cp.add(grid);

c.add(cp);
}


public Widget asWidget() {
return this;
}


and PersonDTO is as follows

public class PersonDTO extends BeanModel implements Serializable {


private static final long serialVersionUID = -634708820353723786L;
private Integer id;
private String firstName;

------------

My actual DTO has more than 15 attributes but I want to diaply only 5 in my grid. Is that a problem.

Can someone please tell me what I might be doing wrong

sven
6 Nov 2011, 3:15 AM
That is not a simple standalone testcase implementing EntryPoint. That are just code snippets. You really should take the time to reproduce your issue in a small standalone testcase that everyone can run, so your problem can get resolved.

atlanta.peter
6 Nov 2011, 11:19 AM
Ok. I finally found the issue.

For my Bean I was extending BeanModel like this

public class PersonDTO extends BeanModel implements Serializable{

which did not work.I thought this should work because I found this info from a lot of examples online and in may forums. What actually worked was the below

public class PersonDTO implements BeanModelTag,Serializable{

and in my view use this

private BeanModelFactory factory = BeanModelLookup.get().getFactory( PersonDTO.class );

ListStore<BeanModel> store = new ListStore<BeanModel>();

store.add( factory.createModel( new PersonDTO(---- some data) );

Thanks for the help. I was nice to know someone was looking at your request.