4

我希望我的表列之一有一个 deleteButton。

ActionCell<Entrata> deleteCell = new ActionCell<Entrata>("x",new Delegate<Entrata>() {
            @Override
            public void execute(Entrata object) {
                // rpc stuff.... 
            }
        });

好的,但是这一行会产生一个错误:

Column<Entrata,Entrata> deleteColumn = new Column<Entrata, Entrata>(deleteCell);

“无法实例化类型列”

你怎么看?

4

3 回答 3

1

在这里,您可以使用工作代码:

假设:

TYPE - 您在 Cell Table 的行中显示的数据的类是否相同,因为我假设您要在删除数据实例时引用它

public class DeleteColumn extends Column<TYPE, TYPE>
{
    public DeleteColumn()
    {

        super(new ActionCell<TYPE>("Delete", new ActionCell.Delegate<TYPE>() {
            @Override
            public void execute(TYPE record)
            {
                /**
                  *Here you go. You got a reference to an object in a row that delete was clicked. Put your "delete" code here
                  */
            }
        }));
    }

    @Override
    public TYPE getValue(TYPE object)
    {
        return object;
    }
};
于 2011-08-12T01:02:14.840 回答
0

从独库:

表中列的表示形式。该列可以按需维护每个单元格的视图数据。如果需要,新的视图数据由单元格的 onBrowserEvent 方法创建,存储在 Column 中,并传递给以后对 Cell 的调用

所以你必须像这样声明它:

    Column<String, String> colum = new Column<String, String>(null) {

        @Override
        public String getValue(String object) {
            // TODO Auto-generated method stub
            return null;
        }
    };

我仍然不完全知道你是如何实现删除按钮的,所以如果你能把剩下的代码给我们就好了。

于 2011-08-11T21:15:59.603 回答
0

这有效

//table = initialized CellTable with content already loaded 

ActionCell editCell = new ActionCell<EmployeeObject>("remove", new ActionCell.Delegate<EmployeeObject>() {
            public void execute(EmployeeObject object){
                List<EmployeeObject> list = new ArrayList<EmployeeObject>(table.getVisibleItems());
                for(int i = 0; i < list.size(); i ++){
                    if(object.getFirstname().equals(list.get(i).getFirstname())){
                        list.remove(i);
                        break;
                    }
                }
                table.setRowData(list);
            }
        });

Column<EmployeeObject, ActionCell> editColumn = (new IdentityColumn(editCell));
于 2012-06-21T10:31:16.870 回答