1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default Adding event handleras to Grid rows.

    Adding event handleras to Grid rows.


    I need to add a dblclick handler to rows on my Grid. Double clicking on a row will switch to another tab in which the contents of the row are edited in a form.

    How can I add a dblclick handler?

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    There is no standard way in the current version. In the new release coming shortly, the grid has a much improved event system. Direct access to the YAHOO.util.CustomEvent object has been deprecated (although will still work for now) and the new way is using a more standard addListener:

    yourGrid.addListener('rowdblclick', yourHandler);

    Your handler might look like this:
    Code:
     // grid passed for convenience to handlers
    function yourHandler(grid, rowIndex){
         var id = grid.getDataModel().getRowId(rowIndex);
         launchTab(id);
    }
    The new events exposed by the grid object directly:

    // raw events
    'click'
    'dblclick'
    'mousedown'
    'mouseup'
    'mouseover'
    'mouseout'
    'keypress'
    'keydown'

    // calculated events
    'cellclick'
    'celldblclick'
    'rowclick'
    'rowdblclick'
    'headerclick'
    'rowcontextmenu'
    'headercontextmenu'
    'beforeedit'
    'afteredit',
    'bodyscroll'

    Raw events give access to the raw browser event for the entire grid, calculated events are for items within the grid.

    Anyway, you could do it with version .31 but it would take a little more code:
    Code:
    var ct = getEl('your-grid-container');
    // use 'mon' instead of 'on' to get a managed (normalized) event object
    ct.mon('dblclick', yourHandler);
    
    // assumes grid object is global
    function yourHandler(e){
         var row = yourGrid.getRowFromChild(e.getTarget());
         if(row) {  // need this check in case they double clicked header instead of row
             var id = yourGrid.getDataModel().getRowId(row.rowIndex);
             launchTab(id);
        }
    }
    So it's possible now, but in the next release it will much easier.

    Jack

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,545
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    The next realease sounds superb. Once again, I'm impressed by your innovation and work rate. Any idea when the next release will be available?

    If it's soon, I'll probably wait, and just hang a listener on the rowdblclick event.

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Thanks. My personal deadline for the next release is next Monday (Sept 25th). Whether I hit that is mostly dependent on whether or not I can get the documentation done. There's a ton of new stuff and I want make sure I document everything so people will actually use it.

Similar Threads

  1. Grid: Dinamycally adding and removing rows
    By tabo in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 31 Mar 2007, 3:57 PM
  2. Adding event to radio group through Ext?
    By Saeven in forum Ext 1.x: Help & Discussion
    Replies: 4
    Last Post: 21 Mar 2007, 10:32 AM
  3. Trouble adding rows to grid manually.
    By kjordan in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 9 Mar 2007, 3:22 PM
  4. Faulty DomHelper.Template behaviour while adding table rows
    By manugoel2003 in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 20 Jan 2007, 1:37 AM
  5. Adding Grid to ContentPanel
    By griffiti93 in forum Community Discussion
    Replies: 6
    Last Post: 23 Nov 2006, 11:18 AM

Thread Participants: 1