Reputation: 2212
i am facing a problem with using the smartGWT CloseClickHandler
, i added it to a tab , it is working good but my problem is, that it delete tha tab before i can do any thing with the event , what i want is to be able to show a confirmation window so the user can be sure he want to close the tab ,
so is there any handler that can do my code before deleting or hiding the tab Or is there any way to handle this situation using the tab CloseClickHandler ?
my code is :
tabSet = new TabSet();
tabSet .setWidth100();
tabSet .setOverflow(Overflow.HIDDEN);
tabSet .setTabBarThickness(23);
tabSet .setHeight(23);
tabSet .setBackgroundColor("#e1dfdf");
tabSet .setCanCloseTabs(true);
tabSet .setCloseTabIcon("icons/close_icon.png");
tabSet .setCloseTabIconSize(12);
tabSet .addCloseClickHandler(new CloseClickHandler() {
public void onCloseClick(TabCloseClickEvent event) {
final int tabIndex = ((MyTab)event.getTab()).getId();
final MyTab = (MyTab)tabSet.getTab(tabIndex);
int tabId = tab.getTabId();
int tabType = getType();
presenter.removeBasket(tabId, tabType);
}
});
Upvotes: 0
Views: 626
Reputation: 46841
Try this one.
First cancel the TabCloseClickEvent
then do whatever you want to do.
tabSet.addCloseClickHandler(new com.smartgwt.client.widgets.tab.events.CloseClickHandler() {
@Override
public void onCloseClick(TabCloseClickEvent event) {
event.cancel();
final Tab tab = event.getTab();
SC.confirm("Are you sure? You want to delete " + tab.getTitle()+" tab.",
new BooleanCallback() {
@Override
public void execute(Boolean value) {
if (value != null && value) {
tabSet.removeTab(tab);
}
}
});
}
});
Upvotes: 1