Adding button to the GXT Grid cell

2019-07-10 12:46发布

I use GXT 2.2.0 and I need to make a button for deleting rows. It was an idea to make checkboxes and create a button "delete", but I already have checkbox for choosing rows by users to use them further and decided it is not "user-friendly". So how to add button to the cell?

1条回答
时光不老,我们不散
2楼-- · 2019-07-10 13:36

to add the button to the cell I had to do this:

        column = new ColumnConfig();
        column.setRenderer(new GridCellRenderer() {
            @Override
            public Object render(ModelData model, String property, ColumnData config,                      int rowIndex, int colIndex, ListStore store, Grid grid) {

                final int row = store.indexOf((PropertyItem) model);

                Button b = new Button("remove", new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        Window.alert("row index= " + row);
                        remove(row, customerId);
                    }
                });

                b.setIconStyle("/gxt/images/gxt/icons/delete.png");
                return b;
            }
        });
查看更多
登录 后发表回答