有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java将ActionCell添加到GWT数据网格

我正在尝试将actioncell添加到GWT数据网格,但在这样做时遇到了问题。我查看了GWT showcase,发现了一个将actioncell添加到celltable的示例,如下所示

// ActionCell.
    addColumn(new ActionCell<ContactInfo>(
        "Click Me", new ActionCell.Delegate<ContactInfo>() {
          public void execute(ContactInfo contact) {
            Window.alert("You clicked " + contact.getFullName());
          }
        }), "Action", new GetValue<ContactInfo>() {
      public ContactInfo getValue(ContactInfo contact) {
        return contact;
      }
    }, null);

这是我的尝试,但我不知道这在句法上应该是什么样子,它是如何工作的

Column<OpInventory, ActionCell<OpInventory>> checkColumn = new Column<OpInventory,
//I get an error on instantiating the Delegate
ActionCell<OpInventory>>(new ActionCell("x", new ActionCell.Delegate<OpInventory>())) {
            //this is wrong here
        @Override
        public ActionCell getValue(OpInventory object) {
            // TODO Auto-generated method stub
            return null;
        }

        };
    table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    table.setColumnWidth(checkColumn, 40, Unit.PX);

共 (1) 个答案

  1. # 1 楼答案

    找出语法,在这里发布给其他人

    @SuppressWarnings({ "unchecked", "rawtypes" })
            Column<OpInventory, ActionCell> actionCellColumn = new Column<OpInventory, ActionCell>(new ActionCell("See Lots", new ActionCell.Delegate<OpInventory>() {
    
                @Override
                public void execute(OpInventory object) {
                    // TODO Auto-generated method stub
    
                }
            })){
    
                @Override
                public ActionCell getValue(OpInventory object) {
                    // TODO Auto-generated method stub
                    return null;
                }
    
            };
            table.addColumn(actionCellColumn, "See Lot Numbers");
            table.setColumnWidth(actionCellColumn, 40, Unit.PX);