Oops Null Pointer

Java programming related

GXT Grids – Enable text selection

In GXT the grids have text selection disabled by default (possibly for good reason). I haven’t found out any disadvantages to enabling text selection yet, so here is the code and go and copy and paste freely from grids to Excel…

final Grid<Stock> grid = new Grid<Stock>(store, cm);

grid.addListener(Events.Render, new Listener<BaseEvent>() {
    public void handleEvent(BaseEvent be)
    {
        grid.disableTextSelection(false);
    }
});

Update: I have seen some references to using:

grid.removeStyleName("x-unselectable");

Also in the newer versions of GXT I don’t think you need to add the listener any more (I haven’t confirmed this).

Advertisements

2 responses to “GXT Grids – Enable text selection

  1. Miguel Losa November 24, 2009 at 4:59 pm

    Congratulations! It works. There are lots of forums asking for this solution.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: