1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    14
    Answers
    1
    Vote Rating
    0
    travelbug is on a distinguished road

      0  

    Default 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? &nbsp;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>

  2. Awesome! This is exactly what I was looking for. Thank you! =)

  3. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,717
    Answers
    109
    Vote Rating
    89
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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();
      }
    });

  4. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    14
    Answers
    1
    Vote Rating
    0
    travelbug is on a distinguished road

      0  

    Default


    Awesome! This is exactly what I was looking for. Thank you! =)

Thread Participants: 1