Question

I try to add button into rowExpander content: so i have:

ButtonCell<Integer> viewButtonCell = new ButtonCell<Integer>();

and row expander

RowExpander<XX> expander = new RowExpander<XX>(identity, new AbstractCell<XX>() {
        @Override
        public void render(Context context, XX value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<span>");
            viewButtonCell.render(context, value.getId(), sb);
            sb.appendHtmlConstant("</span>");
        }

ButtonCell is rendered OK i can see it BUT I cannot click it, no selecthandler from ButtonCell is call :(. Any ideas how can I make selectHandlerActive for this button ?

Thanks

Was it helpful?

Solution

i created some new RowExpander :

public class MTPRowExpander<M> extends RowExpander<M> {

    public static int id = 0;

    public static interface WidgetFactory<M> {
        public Widget createWidget(M model);
    }

    private WidgetFactory<M> wf;
    private Set<Integer> expandedRows;

    public MTPRowExpander(IdentityValueProvider<M> valueProvider,WidgetFactory<M> wf) {
        this(valueProvider,GWT.<RowExpanderAppearance<M>> create(RowExpanderAppearance.class),wf);
    }

    public MTPRowExpander(IdentityValueProvider<M> valueProvider,final RowExpanderAppearance<M> appearance, WidgetFactory<M> wf) {
        super(valueProvider, null, appearance);
        this.wf = wf;
        expandedRows = new HashSet<Integer>();
    }

    @Override
    protected boolean beforeExpand(M model, Element body, XElement row,int rowIndex) {
        if (expandedRows.contains(rowIndex)) {
            return true;
        } else {
            expandedRows.add(rowIndex);
            return super.beforeExpand(model, body, row, rowIndex);
        }
    }

    @Override
    protected String getBodyContent(final M model, int rowIndex) {
        final int curentid = id++;
        Scheduler.get().scheduleFinally(new ScheduledCommand() {
            @Override
            public void execute() {
                Widget widget = wf.createWidget(model);
                com.google.gwt.dom.client.Element item = grid.getElement().childElement(".widget" + curentid);
                item.appendChild(widget.getElement());
                ComponentHelper.setParent(grid, widget);
            }
        });
        return "<div class='widget" + curentid + "'></div>";
    }

}

I know that this solution is not perfect but I didnt know how to resolve problem at more proper way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top