Noor
Noor

Reputation: 20178

GWT Cell Tree, Selecting too many options!

I am using a gwt cell tree and I want only one node to be selected in the whole tree but many nodes are being selected.

I am also trying this

S1= new SelectionModel();......
S1.setSelected(S1.getSelected(),false); but using this technique nothing is being selected.

I am having the following problem:alt text

Can someone help??

Upvotes: 0

Views: 1642

Answers (3)

Jens
Jens

Reputation: 1659

You need to provide a key provider to the selection model like this

selectionModel = new SingleSelectionModel<NamedObject>(new ProvidesKey<NamedObject>() {

        @Override
        public Object getKey(NamedObject item) {
            return item.getKey();
        }
    });

This will uniquely identify the nodes in the tree.

Upvotes: 0

Ilia Akhmadullin
Ilia Akhmadullin

Reputation: 1573

Code looks weird to me, because you firstly get selected object with S1.getSelected() command and then kinda re-select same object, so no wonder that nothing happens. Instead S1.getSelected() pass object that you want to select.

Upvotes: 0

Yusuf K.
Yusuf K.

Reputation: 4260

Maybe SingleSelectionModel helps you;

SingleSelectionModel selectionModel = new SingleSelectionModel();

See Google Example 2 to SingleSelectionModel usage.

Upvotes: 2

Related Questions