我有一个带编辑网格的GXT布局容器。要在网格中显示的数据通过GWT-RPC服务获取,然后添加到网格的存储中。问题是网格从未显示任何内容,但我使用IDE的调试器检查了列表不为空(它包含一个元素)。
以下是一些片段:
DTO:
public class CompetitionWinnerDTO extends BaseModelData implements IsSerializable {
public static enum Status implements IsSerializable {
pending, approved, paid
}
public static class Property implements IsSerializable {
public static final String COMPETITION_ID = "competitionId";
public static final String COMPETITION_WINNER_ID = "competitionWinnerId";
public static final String CONFIRM_DATE = "confirmDate";
public static final String SITE_NAME = "siteName";
public static final String PRIZE_NAME = "prizeName";
public static final String PRIZE_VALUE = "prizeValue";
public static final String PAID_DATE = "paidDate";
public static final String WINNER_NAME = "winnerName";
public static final String WINNER_QUOTE = "winnerQuote";
public static final String WINNER_ADDRESS = "winnerAddress";
public static final String WINNER_TOWN = "winnerTown";
}
private Status status;
public CompetitionWinnerDTO() {
setAllowNestedValues(false);
}
public int getCompetitionId() {
return ((Integer) get(Property.COMPETITION_ID)).intValue();
}
public void setCompetitionId(int competitionId) {
set(Property.COMPETITION_WINNER_ID, new Integer(competitionId));
}
public int getCompetitionWinnerId() {
return ((Integer) get(Property.COMPETITION_WINNER_ID)).intValue();
}
public void setCompetitionWinnerId(int competitionWinnerId) {
set(Property.COMPETITION_WINNER_ID, new Integer(competitionWinnerId));
}
public Date getConfirmDate() {
return get(Property.CONFIRM_DATE);
}
public void setConfirmDate(Date confirmDate) {
set(Property.CONFIRM_DATE, confirmDate);
}
public Date getPaidDate() {
return get(Property.PAID_DATE);
}
public void setPaidDate(Date paidDate) {
set(Property.PAID_DATE, paidDate);
}
public String getPrizeName() {
return get(Property.PRIZE_NAME);
}
public void setPrizeName(String prizeName) {
set(Property.PRIZE_NAME, prizeName);
}
public int getPriceValue() {
return ((Integer) get(Property.PRIZE_VALUE)).intValue();
}
public void setPrizeValue(int prizeValue) {
set(Property.PRIZE_VALUE, new Integer(prizeValue));
}
public String getSiteName() {
return get(Property.SITE_NAME);
}
public void setSiteName(String siteName) {
set(Property.SITE_NAME, siteName);
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getWinnerName() {
return get(Property.WINNER_NAME);
}
public void setWinnerName(String winnerName) {
set(Property.WINNER_NAME, winnerName);
}
public String getWinnerAddress() {
return get(Property.WINNER_ADDRESS);
}
public void setWinnerAddress(String winnerAddress) {
set(Property.WINNER_ADDRESS, winnerAddress);
}
public String getWinnerTown() {
return get(Property.WINNER_TOWN);
}
public void setWinnerTown(String winnerTown) {
set(Property.WINNER_TOWN, winnerTown);
}
public String getWinnerQuote() {
return get(Property.WINNER_QUOTE);
}
public void setWinnerQuote(String winnerQuote) {
set(Property.WINNER_QUOTE, winnerQuote);
}
}
在UI中初始化网格:
private final List<ColumnConfig> quoteApprovalConfig = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig(CompetitionWinnerDTO.Property.CONFIRM_DATE, "Date Confirmed", 100);
column.setRenderer(TableRenderers.dateTimeRenderer);
quoteApprovalConfig.add(column);
column = new ColumnConfig(CompetitionWinnerDTO.Property.PRIZE_NAME, "Prize", 100);
quoteApprovalConfig.add(column);
column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_NAME, "Winner", 100);
quoteApprovalConfig.add(column);
column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Quote", 300);
final TextArea text = new TextArea();
text.setAllowBlank(false);
text.setPreventScrollbars(true);
column.setEditor(new CellEditor(text));
quoteApprovalConfig.add(column);
column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Prize", 75);
column.setRenderer(new TableRenderers.CurrencyRenderer(DEFAULT_CURRENCY_CODE));
quoteApprovalConfig.add(column);
private final ColumnModel quoteApprovalColumns = new ColumnModel(quoteApprovalConfig);
private final EditorGrid<CompetitionWinnerDTO> quoteApprovalGrid = new EditorGrid<CompetitionWinnerDTO>(quoteApprovalStore, quoteApprovalColumns);
quoteApprovalGrid.setWidth(LeadIntelConstants.SITE_WIDTH - 25 - 15);
quoteApprovalGrid.setAutoWidth(true);
quoteApprovalGrid.setAutoHeight(true);
quoteApprovalGrid.setAutoExpandColumn(CompetitionWinnerDTO.Property.WINNER_NAME);
quoteApprovalGrid.setBorders(true);
quoteApprovalGrid.setStripeRows(true);
我调用GWT-RPC服务并用结果填充商店的代码:
private void refreshQuoteApproval() {
competitionService.getCompetitionWinners(
CompetitionWinnerDTO.Status.pending, new AsyncCallback<List<CompetitionWinnerDTO>>() {
@Override
protected void onSuccess(List<CompetitionWinnerDTO> result) {
setQuoteApprovalWinners(result);
}
});
}
private void setQuoteApprovalWinners(List<CompetitionWinnerDTO> quoteApprovalWinners) {
quoteApprovalStore.removeAll();
if (quoteApprovalWinners != null) {
quoteApprovalStore.add(quoteApprovalWinners);
}
}
正如我所说,我可以看到返回的列表不为空,执行到达quoteApprovalStore.add(quoteApprovalWinners);
没有任何问题,列表包含一个元素。
任何帮助都将不胜感激。
答案 0 :(得分:1)
对,我发现了问题,有两列具有相同的ID:
这一个:
column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Quote", 300);
和另一个:
column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Prize", 75);
只是将后者的id更改为唯一的ID就解决了这个问题。
P.S。:如果GXT可以警告这个
那将是很好的