Alonso Dominguez
Alonso Dominguez

Reputation: 7858

GXT Editor Grid not showing any rows

I have GXT layout container with an editor grid. The data to be shown in the grid is fetched via a GWT-RPC service and then added to the grid's store. The problem is the grid never shows anything but I checked using my IDE's debugger that the list is not empty (it contains one element).

Here are some snippets:

The 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);
    }

}

Initialization of the grid in the 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);

And the code where I invoke the GWT-RPC service and fill the store with the results:

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);
    }
}

As I said, I can see that returned list is not empty, execution reaches quoteApprovalStore.add(quoteApprovalWinners); without any problem and the list contains one element.

Any help would be appreciated.

Upvotes: 1

Views: 1188

Answers (1)

Alonso Dominguez
Alonso Dominguez

Reputation: 7858

right, I found the problem, there were two columns with the same ID:

this one:

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

and this other one:

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

just changing the latter's id to a unique one solved the issue.

P.S.: It would be great if GXT could warn about this

Upvotes: 1

Related Questions