CellTable:数据在所有列中重复
我是这里和 GWT 的新手。 嗯,我对 CellTable 有一些疑问...我对这个问题感到非常不安。 问题是:当我创建 setRowData 或 ListDataProvider.setList 时,列表中的所有数据都会在所有列上重复。如果列表中有 11 个数据,则所有 11 个数据在 11 行和所有列中重复。 为了更好地解释问题的形象。
http://imageshack.us/photo/my-images/713/celltable。 jpg/
我不知道我必须做什么来解决此类“问题”。 无论如何,我将发布代码:
//TABLE CODE
tablePesquisaResultados = new CellTable<String>();
tablePesquisaResultados.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
tablePesquisaResultados.setTableLayoutFixed(true);
tablePesquisaResultados.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
flexTable.setWidget(2, 0, tablePesquisaResultados);
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 10, true);
pager.setDisplay(tablePesquisaResultados);
tablePesquisaResultados.setWidth("1262px");
colID = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colID, "ID");
colNomeUsuario = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colNomeUsuario, "Nome do Usuário");
colEmail = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colEmail, "Email");
colCodigoUsuario = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colCodigoUsuario, "Código do Usuário");
colTelefone = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colTelefone, "Telefone");
colCodigoSituacao = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colCodigoSituacao, "Código da Situação");
colDataAbertura = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDataAbertura, "Data de Abertura");
colDataEncerramento = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDataEncerramento, "Data de Encerramento");
colDescricao = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDescricao, "Descrição do Chamado");
colMidiaAnexada = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colMidiaAnexada, "Mídia Anexada");
colStatusID = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colStatusID, "Status ID");
flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
FlexTableHelper.fixRowSpan(flexTable);
//END TABLE CODE
//CODE TO INSERT DATA IN CELLTABLE
ListDataProvider<String> dataProvider = new ListDataProvider<String>();
dataProvider.addDataDisplay(tablePesquisaResultados);
dataProvider.setList(resultado);
System.out.println(resultado);
//END CODE TO INSERT DATA IN CELLTABLE
嗯,有。
谢谢,建议。
i'm a newbie here and in GWT.
Well, i have some questions with CellTable... And i'm very upset with the problem.
The problem is: When i make a setRowData or ListDataProvider.setList, all the data in the List i have repeats at all Columns. If i have 11 datas on the list, all 11 data repeats in 11 rows and all columns.
To explain better, the image of issue.
http://imageshack.us/photo/my-images/713/celltable.jpg/
I don't know what i have to do to resolve this type of "problem".
Anyway, i will post the code:
//TABLE CODE
tablePesquisaResultados = new CellTable<String>();
tablePesquisaResultados.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION);
tablePesquisaResultados.setTableLayoutFixed(true);
tablePesquisaResultados.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE);
flexTable.setWidget(2, 0, tablePesquisaResultados);
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 10, true);
pager.setDisplay(tablePesquisaResultados);
tablePesquisaResultados.setWidth("1262px");
colID = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colID, "ID");
colNomeUsuario = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colNomeUsuario, "Nome do Usuário");
colEmail = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colEmail, "Email");
colCodigoUsuario = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colCodigoUsuario, "Código do Usuário");
colTelefone = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colTelefone, "Telefone");
colCodigoSituacao = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colCodigoSituacao, "Código da Situação");
colDataAbertura = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDataAbertura, "Data de Abertura");
colDataEncerramento = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDataEncerramento, "Data de Encerramento");
colDescricao = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colDescricao, "Descrição do Chamado");
colMidiaAnexada = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colMidiaAnexada, "Mídia Anexada");
colStatusID = new TextColumn<String>() {
@Override
public String getValue(String object) {
return object.toString();
}
};
tablePesquisaResultados.addColumn(colStatusID, "Status ID");
flexTable.getFlexCellFormatter().setColSpan(2, 0, 2);
FlexTableHelper.fixRowSpan(flexTable);
//END TABLE CODE
//CODE TO INSERT DATA IN CELLTABLE
ListDataProvider<String> dataProvider = new ListDataProvider<String>();
dataProvider.addDataDisplay(tablePesquisaResultados);
dataProvider.setList(resultado);
System.out.println(resultado);
//END CODE TO INSERT DATA IN CELLTABLE
Well, there is.
Thanks, in advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是,对于每一列,您都使用相同的
getValue
函数:每列都需要特定的函数来返回要在该列中显示的值。例如对于
colNomeUsuario
列:编辑
我刚刚注意到您定义单元格表的方式:
您需要这样定义它:
其中 MyObject 是一个类,表示您想要在单元格表中显示的信息。
您可以使用 Request Factory 将服务器对象传递到客户端,或者 < a href="http://code.google.com/webtoolkit/doc/latest/tutorial/RPC.html" rel="nofollow">GWT RPC。
The problem is that for each column you use the same
getValue
function:You need specific functions for each column that return the value that you want to display in that column. For example for column
colNomeUsuario
:Edit
I just noticed the way you define your celltable:
You need to define it like this:
Where MyObject is a class representing the information that you want to display in the celltable.
You can pass server objects to the client side using Request Factory, or GWT RPC.