如何在GWTP中创建动态表
我是GWTP的新用户,不知道如何在GWTP中创建表。我知道如何用GWT制作一个如何在GWTP中创建动态表,gwt,smartgwt,gwtp,gwt-platform,gwt-places,Gwt,Smartgwt,Gwtp,Gwt Platform,Gwt Places,我是GWTP的新用户,不知道如何在GWTP中创建表。我知道如何用GWT制作一个 // Create a CellTable. CellTable<Contact> table = new CellTable<Contact>(); // Create name column. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override public Strin
// Create a CellTable.
CellTable<Contact> table = new CellTable<Contact>();
// Create name column.
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.name;
}
};
但这在GWTP中似乎不起作用。有人能帮我获取GWTP程序中按下按钮时的值吗。我知道你一周前问了这个问题,但你可能仍然无法回答,所以继续。您只需确保在Presenter和View中分别放置了正确的逻辑位 原则上,它与没有GWTP的MVP Model View Presenter没有什么不同: 演示者的任务是获取数据以填充CellTable,并将其传递给视图: 然后在您的UiBinder中:
<g:HTMLPanel>
<b:CellTable ui:field="table" />
</g:HTMLPanel>
我没有使用它,但我认为有一个ActionCell和ButtonCell类您可能可以使用。试着用谷歌搜索其中一个,看看是否有帮助。
public class TableView extends View implements TablePresenter.MyView
{
@UiField
CellTable<Contact> table;
// use a dataprovider to hold the data
private ListDataProvider<Contact> dataProvider = new ListDataProvider<Contact>();
// COLUMNS
TextColumn<Contact> nameColumn;
Column<Contact, String> buttonColumn;
@Inject
public AccountsView(Binder uiBinder)
{
initWidget(uiBinder.createAndBindUi(this));
initTable();
}
private void initTable()
{
nameColumn = new TextColumn<Contact>()
{
@Override
public String getValue(Contact object)
{
return object.name;
}
};
// now add the column to the table
table.addColumn(nameColumn, "Name");
buttonColumn = new Column<Contact, String>(new ButtonCell())
{
// the text of the button
@Override
public String getValue(Contact object)
{
return "Delete " + object.name;
}
};
// set the button action
deleteColumn.setFieldUpdater(new FieldUpdater<Contact, String>()
{
@Override
public void update(int index, Contact object, String value)
{
// whatever you want to do when you click the button
Window.alert("You pressed " + object.name);
}
});
fileTable.addColumn(deleteColumn);
// link dataprovider to the table
dataProvider.addDataDisplay(table);
}
@Override
public void addData(List<Contact> contacts)
{
// clear the dataProvider's list
dataProvider.getList().clear();
// pass the data into the list
dataProvider.setList(contacts);
}
}
<g:HTMLPanel>
<b:CellTable ui:field="table" />
</g:HTMLPanel>