1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    7
    Vote Rating
    0
    dubaut is on a distinguished road

      0  

    Default Clieck/DoubeClick Event on Tree leafs

    Clieck/DoubeClick Event on Tree leafs


    Is there any way to handle Click/DoubleClick Events on Tree leafs?

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    What have you tried?

    You can listen to all click (or doubleclick) events on the Tree or TreeGrid via addDomHandler. You'll then need to ask the tree/treegrid's view for details about which model was represented in that click (if any - they might click in empty space or a header).

    In a TreeGrid you can listen for all row clicks and doubleclicks and all cell clicks and double clicks (addRow/CellClick/DoubleClickHandler methods). The event will offer additional details about what was clicked.

    In either you can provide a custom cell with a onBrowserEvent method to give you the model object and the entire cell that was clicked. Example with Tree (applies to any cell widget in GXT or GWT): http://www.sencha.com/examples/#Exam...cellactiontree

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    7
    Vote Rating
    0
    dubaut is on a distinguished road

      0  

    Default


    Quote Originally Posted by Colin Alworth View Post
    What have you tried?
    [..]
    In either you can provide a custom cell with a onBrowserEvent method to give you the model object and the entire cell that was clicked. Example with Tree (applies to any cell widget in GXT or GWT): http://www.sencha.com/examples/#Exam...cellactiontree
    I tried exactly this and all I got is the value of the leaf.

    Is there any way to access further information about the leaf the event has been fired on?

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    Can you be more specific? The 'value' is what the leaf represents, the 'element' is the actual dom node that is drawn on the screen. What more are you looking for?

  5. #5
    Sencha User
    Join Date
    Mar 2013
    Posts
    7
    Vote Rating
    0
    dubaut is on a distinguished road

      0  

    Default


    Quote Originally Posted by Colin Alworth View Post
    Can you be more specific? The 'value' is what the leaf represents, the 'element' is the actual dom node that is drawn on the screen. What more are you looking for?
    To have a simple example: Imagine the tree is supposed to represent a file system and the leafs only show the current file name. How could I determine if the click was fired on a node (representing a directory) or on a leaf (representing a file)? How could I determine what node and what leaf has been clicked?

    I took the file system example because it's understandable that there can be different files with the same name in different folders.

  6. #6
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    In that case, the model that was passed in, the object that the cell is rendering should have that meta data. If you choose deliberately to not have the Tree know about that model (i.e. a Tree<FileSystemObject, String>), then one of the other approaches might make more sense. That said, the only reason to deliberately make the tree cells not know about that model is to make it easier to render, but if you are making it now harder to listen to events, then it sounds like that isn't a good idea after all. Make it a Tree<FileSystemObject, FileSystemObject> so that the cell gets the FileSystemObject as a value - you'll need a custom render method to draw correctly, but now you'll have a easier time with the model.

    Other options:
    - you can use the Element passed in with Tree.findNode to get a TreeNode and call getModel() on that.
    - see the other choices above. Also, consider just configuring a selection model for click or double click, and listening to SelectionEvent<M> of your model.

  7. #7
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,639
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    If you post a runnable sample that almost does what you need, it will be easier to make concrete suggestions.

  8. #8
    Sencha User
    Join Date
    Mar 2013
    Posts
    7
    Vote Rating
    0
    dubaut is on a distinguished road

      0  

    Default


    I like the approach with the custom render method! Is there any examples how to deal with custom render methods?

    Thanks for your answers so far!

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar