CellTable:数据在所有列中重复

发布于 2024-12-18 02:23:52 字数 4263 浏览 1 评论 0原文

我是这里和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纵情客 2024-12-25 02:23:52

问题是,对于每一列,您都使用相同的 getValue 函数:

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

每列都需要特定的函数来返回要在该列中显示的值。例如对于 colNomeUsuario 列:

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

编辑

我刚刚注意到您定义单元格表的方式:

tablePesquisaResultados = new CellTable<String>();

您需要这样定义它:

tablePesquisaResultados = new CellTable<MyObject>();

其中 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:

@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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文