-
18 Sep 2006 4:51 AM #1
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?
-
18 Sep 2006 12:36 PM #2
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:
The new events exposed by the grid object directly:Code:// grid passed for convenience to handlers function yourHandler(grid, rowIndex){ var id = grid.getDataModel().getRowId(rowIndex); launchTab(id); }
// 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:
So it's possible now, but in the next release it will much easier.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); } }
Jack
-
18 Sep 2006 11:24 PM #3
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.
-
19 Sep 2006 11:02 AM #4
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
-
Grid: Dinamycally adding and removing rows
By tabo in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 31 Mar 2007, 3:57 PM -
Adding event to radio group through Ext?
By Saeven in forum Ext 1.x: Help & DiscussionReplies: 4Last Post: 21 Mar 2007, 10:32 AM -
Trouble adding rows to grid manually.
By kjordan in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 9 Mar 2007, 3:22 PM -
Faulty DomHelper.Template behaviour while adding table rows
By manugoel2003 in forum Ext 1.x: Help & DiscussionReplies: 9Last Post: 20 Jan 2007, 1:37 AM -
Adding Grid to ContentPanel
By griffiti93 in forum Community DiscussionReplies: 6Last Post: 23 Nov 2006, 11:18 AM


Reply With Quote