PDA

View Full Version : ComboBox ContextMenu?



eggp
6 Nov 2011, 5:26 AM
Hello

I create a advanced combobox , but i can not add a context menu ... WHY?


package hu.eggproject.pizzapiazza.admin.client.views.portlets.UserSearch;

import hu.eggproject.pizzapiazza.admin.client.controllers.AjaxController.HttpProxy;


public class UserSearch extends Portlet
{
private ListStore<User> store;
protected FastMap<String> getParams;
private ComboBox<User> cmbxCsaldNv;


public UserSearch() {
setHeading("Felhasználó kereső");
setLayout(new FormLayout());

getParams = new FastMap<String>();
getParams.put("action", "get_all_user_model");
HttpProxy<PagingLoadResult<User>> proxy = new HttpProxy<PagingLoadResult<User>>(Controller.getAjaxController(),getParams);
JsonPagingLoadResultReader<PagingLoadResult<User>> reader = new JsonPagingLoadResultReader<PagingLoadResult<User>>(User.getModelType())
{
@Override
protected ModelData newModelInstance() {
return new User(true);
}

};


final PagingLoader<PagingLoadResult<User>> loader = new BasePagingLoader<PagingLoadResult<User>>(proxy, reader);
loader.setRemoteSort(true);

loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>()
{
@Override
public void handleEvent(LoadEvent be) {
BasePagingLoadConfig m = be.<BasePagingLoadConfig> getConfig();
m.set("searchColumn", "first_name");
}

});

this.store = new ListStore<User>(loader);

cmbxCsaldNv = new ComboBox<User>();
cmbxCsaldNv.setStore(this.store);
add(cmbxCsaldNv, new FormData("100%"));
cmbxCsaldNv.setFieldLabel("Család név");
cmbxCsaldNv.setDisplayField("displayName");
cmbxCsaldNv.setItemSelector("div.search-item");
cmbxCsaldNv.setTemplate(this.getTemplate());
cmbxCsaldNv.setHideTrigger(true);
cmbxCsaldNv.setPageSize(20);
cmbxCsaldNv.setEmptyText("Ide a teljes névből kell begépelni minimum 3 karaktert...");
cmbxCsaldNv.setMinChars(3);
//cmbxCsaldNv.getListView().setContextMenu(createListViewContextMenu());
//cmbxCsaldNv.setContextMenu(createListViewContextMenu());
cmbxCsaldNv.addListener(Events.Attach, new Listener<BaseEvent>()
{
@Override
public void handleEvent(BaseEvent be)
{
cmbxCsaldNv.getListView().setContextMenu(createListViewContextMenu());
}

});


this.getHeader().addTool(new ToolButton("x-tool-close",new SelectionListener<IconButtonEvent>()
{
@Override
public void componentSelected(IconButtonEvent ce)
{
hide();
}
}));

this.getHeader().addTool(new ToolButton("x-tool-maximize",this.createMaximizeToolButtonSelectionListener()));
}

protected Menu createListViewContextMenu()
{
Menu contextMenu = new Menu();
MenuItem mi = new MenuItem("Adatok szerkesztése");
mi.addSelectionListener(createAdatokSzerkeszteseListener());
contextMenu.add(mi);

mi = new MenuItem("Adatok megtekintése");
mi.addSelectionListener(createAdatokMegtekinteseListener());
contextMenu.add(mi);

return contextMenu;
}

protected SelectionListener<? extends MenuEvent> createAdatokMegtekinteseListener()
{
return new SelectionListener<MenuEvent>()
{
@Override
public void componentSelected(MenuEvent ce)
{
Controller.getDesktopController().createWindow("UserView", "UserView", true, true, cmbxCsaldNv.getListView().getSelectionModel().getSelectedItem());
}
};
}


protected SelectionListener<? extends MenuEvent> createAdatokSzerkeszteseListener()
{
return new SelectionListener<MenuEvent>() {


@Override
public void componentSelected(MenuEvent ce)
{
Controller.getDesktopController().createWindow("UserEdit", "UserEdit", true, false,cmbxCsaldNv.getListView().getSelectionModel().getSelectedItem());
}
};
}

protected SelectionListener<IconButtonEvent> createMaximizeToolButtonSelectionListener()
{
return new SelectionListener<IconButtonEvent>()
{
@Override
public void componentSelected(IconButtonEvent ce)
{
hide();
try {
Controller.getDesktopController().getWindow("UsersGrid").show();
} catch (Exception e) {
// TODO Auto-generated catch block
Controller.reportError(e);
}
}
};
}

private native String getTemplate() /*-{
return [
'<tpl for="."><div class="search-item">',
'<p>{displayName}</p>',
'</div></tpl>'
].join("");
}-*/;

}




this my code... i have tried combobox.setContextmenu or combobox listView context menu ..., but not appear in the menu....

Thx
Egg

PS:
I translate to google....