gpt4 book ai didi

java - GXT 编辑器网格不显示任何行

转载 作者:太空宇宙 更新时间:2023-11-04 08:12:43 25 4
gpt4 key购买 nike

我有带有编辑器网格的 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); 没有任何问题,并且列表包含一个元素。

如有任何帮助,我们将不胜感激。

最佳答案

对了,我发现问题了,有两列的ID相同:

这个:

column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Quote", 300);

还有另一个:

column = new ColumnConfig(CompetitionWinnerDTO.Property.WINNER_QUOTE, "Prize", 75);

只需将后者的 id 更改为唯一的 id 即可解决问题。

P.S.:如果 GXT 能够对此发出警告,那就太好了

关于java - GXT 编辑器网格不显示任何行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10914785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com