3

I have a DTO object with fields:

public class EmpDTO extends BaseModel implements java.io.Serializable {
    private short empno;
    private EmpDTO emp;
    private DeptDTO dept;
    private String ename;
    private String job;

I try output this class in the grid:

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig clmncnfgEname = new ColumnConfig("ename", "ename", 150);
configs.add(clmncnfgEname);
ListStore<EmpDTO> store = new ListStore<EmpDTO>();
EmpDTO empDTOtmp = new EmpDTO();
empDTOtmp.setEname("Name");
store.add(empDTOtmp);
Grid<EmpDTO> grid = new Grid<EmpDTO>(store, new ColumnModel(configs));
mainContentPanel.add(grid);

But i see empty grid with out error. How to fix this?

Selector
  • 506
  • 1
  • 6
  • 21

2 Answers2

1

Do you have to use BaseModel? Rather than extending BaseModel why not implement BeanModelTag?

public class EmpDTO implements BeanModelTag {

Otherwise make sure setEname looks like this:

public void setEname(String ename) {
  set("ename",ename);
}

And getEname looks like this:

public String getEname() {
   return (String)get("ename");
}
Terrell Plotzki
  • 2,014
  • 17
  • 17
  • Yes i do use BaseModel and implement Serializable. My getters and setters look like this: public String getEname() { return this.ename; } public void setEname(String ename) { this.ename = ename; } – Selector Sep 23 '11 at 06:46
  • You will have to modify your getters & setters. You need to perform those calls to set the string properties if you are using this as a baseModel. See here: [http://www.sencha.com/forum/showthread.php?65999-How-to-use-BaseModel-and-BaseModelData](http://www.sencha.com/forum/showthread.php?65999-How-to-use-BaseModel-and-BaseModelData) – Terrell Plotzki Sep 23 '11 at 13:34
0

Go through this link ... I think you might be missing out on some key steps to setup a grid. http://zawoad.blogspot.com/2009/08/how-to-create-simple-grid-using-gxtext.html

It shows through simple steps on how to create a GXT based grid and helped me out a lot. Also personally I have had this issue on some occasions. Make sure your DTO fields have been correctly mapped to the Grid column config. This might be the problem.

I would recommend you to go through the above post and cross check your grid implementation.

Manoj
  • 69
  • 5