Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Why filterData() on a Menu does mute the addItemClickHandler() behavior?

    Why filterData() on a Menu does mute the addItemClickHandler() behavior?

    -> It is a cast problem

    Here is a how to handle this:
    Code:
    grid.addRowContextClickHandler(new RowContextClickHandler()
    {
        public void onRowContextClick(RowContextClickEvent event)
        {
            final ListGrid listGrid = (ListGrid) event.getSource();
            Criteria criteria = new Criteria();
            for (ListGridRecord rec : listGrid.getSelection())
                criteria.addCriteria("ID", rec.getAttribute("ID"));
            final Menu contextMenu = listGrid.getContextMenu();
            contextMenu.filterData(criteria, new DSCallback()
            {
                public void execute(DSResponse response, Object rawData, DSRequest request)
                {
                    Record[] data = response.getData();
                    MenuItem[] items = new MenuItem[data.length];
                    int i = 0;
                    for (Record rec : data)
                        items[i++] = (MenuItem) rec;
                    contextMenu.setItems(items);
                }
            });
        }
    });
    Last edited by enguerran; 21 Jun 2010, 02:06. Reason: an implementation proposition...
Working...
X