user3029642
user3029642

Reputation: 957

How does one dynamically add a row to a GXT grid

I'm attempting to add a row to a GXT grid and failing miserably. I'm trying to build a grid that can be used as an IN filter. It has a DateField and two buttons ADD and REMOVE. ADD should take the date from the date field and add it to the grid. REMOVE should remove the selected item from the grid.

enter image description here

The problem is that, when I add a date the the grid's store, I cannot figure out how to get it to display on the grid. I've tried different combinations of loader.load(), view.refresh(), grid.configure() and fired events.

addButton = new Button("Add");
    addButton.setVisible(true);
    addButton.addSelectionListener(new SelectionListener<ButtonEvent>(){
        @Override
        public void componentSelected(ButtonEvent ce) {
            if(dateField.getValue() != null) {

                GwtDate date = GwtDate.decodeFromJavaDate(dateField.getValue());
                grid.getStore().add(date);
                //grid.getStore().getLoader().load();
                //grid.getView().refresh(true);
                grid.reconfigure(grid.getStore(), grid.getColumnModel());

                fireEvent(Events.Change);
            }

        }
    });

    toolbar.add(addButton);

I can't find much in the way of documentation for these old versions of GWT/GXT so I'm hoping someone can help. Thank you.

GXT version 2.2.3 GWT version 2.2.0

Upvotes: 0

Views: 274

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

The problem is almost certainly one of sizing - the grid inside the menu has been set up with no layout and no size, and is expected to grow to fit its content (since that is how menus usually work), but like many data views, it will not function well without an explicit size given so that it can add scrollbars as needed.

Either give it a size, set up a layout from its parent, or look into the "auto-height grid" example/workaround, making sure that you understand the ramifications of using it.


Also note that GWT 2.2 and GXT 2.2.3 are five years out of date, and GXT 2 was end-of-life'd a year ago when GXT 4 was released. There may be other issues with them and any browser version released since then.

Upvotes: 1

Related Questions