Question

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.

Was it helpful?

Solution

The problem is that for each column you use the same getValue function:

@Override
public String getValue(String object) {
   return object.toString();
}


You need specific functions for each column that return the value that you want to display in that column. For example for column colNomeUsuario:

colNomeUsuario = new TextColumn<String>() {
   @Override
   public String getValue(String object) {
      return object.getNomeUsuario();
   }
};


Edit

I just noticed the way you define your celltable:

tablePesquisaResultados = new CellTable<String>();


You need to define it like this:

tablePesquisaResultados = new CellTable<MyObject>();

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top