-
5 Aug 2008 10:55 AM #1
Making <A> Link draggable inside Grid, just like row
Making <A> Link draggable inside Grid, just like row
This question was posted here, but there was no exact technical response.
http://extjs.com/forum/showthread.ph...755#post204755
I have a grid, with draggable rows to a tree.
The grid has a rowRenderer which renders one of the cells as an html A href link instead of just the text:
The problem is, that you cant drag the row from the href link now... but you canCode:myRowRenderer=function(value){ return "<a href='javascript:;' onclick='doMyEvent()'>" + value + "</a>"; }
from everwhere else on that row.
It was mentioned in the above thread about passing along the mouse events from
the href link to the row? Can someone show me show to do that?
Im thinking it might be something like this?:
that is not the correct code... but am i on the right track?Code:myRowRenderer=function(value){ return "<a href='javascript:;' onmousedown='myGrid.getSelectionModel().getSelected().fireEvent(mousedown)' onmouseup='myGrid.getSelectionModel().getSelected().fireEvent(mouseup)' onclick='doMyEvent()'>" + value + "</a>"; }
-
5 Aug 2008 12:28 PM #2
Why is that a link with an href of 'javascript:;'? That is a real no-no.
If you want to hook a click event on a cell use the GridPanel's cellclick event. Details in the FAQ.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
5 Aug 2008 12:29 PM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
5 Aug 2008 1:50 PM #4
Imagine a grid as a file explorer.
You click the grid row/cell to select it,
you click the name of the file to open it.
you double click the name to rename it.
how else would you do it?
That means the name of the file has to be an <A> link,
or else selecting it and opening it would conflict.
-
5 Aug 2008 2:13 PM #5
Trees make much more sense as a file explorer analog than a grid...
Also, web browser mouse events dont work the same as mouse events do in windows. You cant have both click and a double click handlers assigned to an object or you get unexpected results.
If you did want to keep using a grid, something like Saki's rowActions plugin makes much more sense anyway. Yeah, its slightly different than a file explorer, but then this is a web browser not an application language; youre going to have to make compromises.
-
7 Aug 2008 12:28 PM #6
When you see the project as a whole, the grid is what makes sense.
Anyways, the issue is not - should i do it another way, its - how do i make this work...
Having one object that is draggable, single-clickable, and double-clickable is not asking too much, its just a matter of figuring it out.
I'll check out the rowactions plugin but it doesnt look like it handles all three events - i could be wrong, i only glanced at it.
Im already using cellclick event for selecting the row, but you miss my point -- There are actually 5 things going on in a single row -- for which, as far as i can tell, arent handled natively by the grid or plugins --Why is that a link with an href of 'javascript:;'? That is a real no-no.
If you want to hook a click event on a cell use the GridPanel's cellclick event.
- Selecting a row (grid click)
- clicking a text link in the row (to produce a different event)
- double-clicking the text link in the row (to rename it)
- dragging the row
- dragging the the row by the text link (or just draggin the text link)
I already got 1-4 done.
#5 is what im not sure about... draggable (making the text link draggable or pass on the drag events to its parent row)
If I have to sculpt my own drag/drop events based on the text links onmousedown/onmouseup events, then thats what i have to do..
-
8 Aug 2008 12:18 AM #7Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
8 Aug 2008 12:58 PM #8
Animal, did you read post #6?
Im already using cell click event.
I want 2 events to occure.
a cell click when the row is clicked...
and a clickevent when the actual text value of one of the cells is clicked, which is currently an A link.
-
9 Aug 2008 1:58 AM #9
Why 2 events? Why not just process the rowclick event?
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
11 Aug 2008 2:30 PM #10
Because I need it to do 2 different things. Clicking the row selects it,
while clicking the name opens it. When I say open, basically do some specialized processing on that item in another frame.
In total, I have 5 events occuring on each row:- Selecting a row (grid click)
- clicking a text link in the row (to produce a different event, opens it)
- double-clicking the text link in the row (to rename it)
- dragging the row
- dragging the the row by the text link (or just draggin the text link)
$20 via paypal if you can show me how...


Reply With Quote
