Reputation: 20862
I have a CellTable being displayed like shown below-
On click of the Delete button I want to open a Popup panel in the center of the screen which should contain a Flow Panel and a Button within it.
Right now for the Delete button I have the following function-
deleteColumn.setFieldUpdater(new FieldUpdater<Contact, String>() {
public void update(int index, Contact object, String value) {
try {
int removeIndex = CONTACTS.indexOf(object);
CONTACTS.remove(removeIndex);
table.setRowCount(CONTACTS.size(), true);
table.setRowData(CONTACTS);
table.redraw();
} catch(Exception e) {
e.printStackTrace();
}});
I do not understand how to update my function for the same. A sample code will surely help.
Upvotes: 1
Views: 2399
Reputation: 260
Something like this?
ButtonCell buttonCell = new ButtonCell(){
@Override
public Set<String> getConsumedEvents() {
// TODO Auto-generated method stub
//return super.getConsumedEvents();
Set<String> events = new HashSet<String>();
events.add("click");
return events;
}
};
productTable.addColumn(new Column<ProductDetails, String>(buttonCell) {
@Override
public String getValue(ProductDetails object) {
// TODO Auto-generated method stub
return "Edit";
}
@Override
public void onBrowserEvent(Context context, Element elem,
ProductDetails object, NativeEvent event) {
// TODO Auto-generated method stub
super.onBrowserEvent(context, elem, object, event);
if("click".equals(event.getType())){
presenter.onEditButtonClicked(object);
}
}
}, "Commands");
Please try it out and let me know the result. I just wrote and havent test it yet :|
Upvotes: 0
Reputation: 17489
How about just displaying a PopupPanel
?
Something like this:
PopupPanel popup = new PopupPanel(true);
FlowPanel panel = new FlowPanel();
//add Button etc
popup.setSize("1100px","500px");
popup.clear();
popup.add(panel);
popup.show();
popup.center();
If you want to display a confirm dialog than this code is easier:
if (Window.confirm("Do you really want to delete the dataset?"))
{
//delete code
}
Upvotes: 2