Hybrid View
-
8 Nov 2012 11:23 PM #1
Answered: How to get the model of the selected checkbox in tree's CheckedChangeHandler event
Answered: How to get the model of the selected checkbox in tree's CheckedChangeHandler event
<div>I am trying to get the tree model whose check box I just checked. I added a CheckedChangedHandler event to the tree to capture this but there doesn't seem to be a method that returns just that one model. I see that there's a getItems() method that returns all the checked items in the tree but is there a way to get the one I just checked? At first I thought the tree.getSelectionModel().getSelectedItem() gave me what I needed but the tree node checked isn't necessarily the item that was selected. I am using GXT 3.0.1.<br><br><br></div>
-
Best Answer Posted by travelbug
Awesome! This is exactly what I was looking for. Thank you! =)
-
9 Nov 2012 11:05 AM #2
There are two slightly different events that fire when check changes, with two slightly different purposes. You've found the CheckChangedEvent, which tells you that "The checked status of this tree has changed, here is the new set of checked items". There is a different one called CheckChangeEvent, which tells "Some item's check property is changing, here is the new status and the node that was modified".
Code:tree.addCheckChangeHandler(new CheckChangeHandler<MyData>() { @Override public void onCheckChange(CheckChangeEvent<MyData> event) { MyData clickedItem = event.getItem(); CheckState state = event.getChecked(); } });
-
9 Nov 2012 11:24 AM #3
Awesome! This is exactly what I was looking for. Thank you! =)


Reply With Quote