【问题标题】:How to make a Non Editable CellTable?如何制作不可编辑的 CellTable?
【发布时间】:2012-09-27 14:38:37
【问题描述】:

我使用这个问题作为指导制作了一个动态 CellTable:Create GWT CellTable Dynamically

但是这样我只能制作一个可编辑的CellTable,我不知道为什么。

检查我的代码:

@UiField
CellTable<List<String>> tableDynamic;
@UiField
SimplePager pagerDynamic;

private SingleSelectionModel<List<String>> 
selectionModelDynamic = new SingleSelectionModel<List<String>>();
private List<String> columns = new ArrayList<String>();
private List<List<String>> data = new ArrayList<List<String>>();
private ListDataProvider<List<String>> providerDynamic 
= new ListDataProvider<List<String>>();

我的工厂

@UiFactory
public CellTable<List<String>> getTabelaDynamic() {
    CellTable<List<String>> table
            = new com.google.gwt.user.cellview.client.CellTable<List<String>>();

    //List<String> columnsArray = colunas;
    List<String> columnsArray = columns();
    for (int column = 0; column < columnsArray.size(); column++) {
        table.addColumn(new IndexedColumn(column), new
                TextHeader(columnsArray.get(column)));
    }
    table.setKeyboardSelectionPolicy
 (HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    table.setSelectionModel(selectionModelDynamic);
    providerDynamic.addDataDisplay(table);
    providerDynamic.setList(new ArrayList<List<String>>());
    return table;
}

获取列的方法:

//Just a static test 
public List<String> columns(){
    colunas.add("Tables");
    return colunas;
}

设置数据只有一列的方法。

@Override
public void setSingleData(List<String> bankData) {
    for (String s : bankData) {
         List<String> help = new ArrayList<String>();
         help.add(s);
         dados.add(help);
    }
    providerDynamic.setList(data);
}

我执行 rpc 调用(onBind 方法)来获取列表并填充 setsingledata 方法。

为什么我会收到一个可编辑的单元格表?

【问题讨论】:

    标签: gwt gwt-platform celltable


    【解决方案1】:

    您的表格是可编辑的,因为 IndexedColumn 在另一个问题中使用了 EditTextCell。使用 TextCell,您的表格将无法编辑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 2019-05-11
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      • 1970-01-01
      相关资源
      最近更新 更多