Clicks and double-clicks

P

PontiMax

Hi,

is it possible to distinguish between clicks and double-clicks occuring on datagrid rows?

If a single row is clicked it should be selected in order to allow various operations like deleting the row, duplicating it, etc.

If a row is double-clicked another event handler should be called that transfers the user to a details page.

Is there a workaround for this using JavaScript?

Thanks in advance,
P.
 
E

Eliyahu Goldin

There is a sequence of events that fire when a row is double-clicked. That
is onmousedown, onmouseup, onclick, onmouseup and finally ondblclick.

If you need to handle events preceding to ondblclick, you should do it on
client side. Then there is no contradiction between row selecting in onclick
and opening another form in ondblclick.

Eliyahu

PontiMax said:
Hi,

is it possible to distinguish between clicks and double-clicks occuring on datagrid rows?

If a single row is clicked it should be selected in order to allow various
operations like deleting the row, duplicating it, etc.
If a row is double-clicked another event handler should be called that
transfers the user to a details page.
 
E

Eliyahu Goldin

OK, that previous post should help you. document.getElementById can't raise
an error, it either find the element or not. The error could be caused by
trying to access non-existent properties of the element. For example, you
assumed the element to be an <input> but it is a <span>.

The direction is to create event handlers in javascript on client side and
to setup attributes on server side. Client side onclick event should save
the id of the row selected in a hidden <input>. Usually it also changes the
row style to distinguish between selected and unselected rows. To delete the
selected row, you would have an asp.net button. On the postback, the
server-side code would get the id from the hidden input and delete the
record with that id.

So, the onclick event only saves the id and changes the style. When the
ondblclick handler gets called, it just submits the form (form.submit() can
be used) and the server-side code again gets the id of the record to edit
from the hidden input.

Sorry if it is messy, the task is a bit involving.

Eliyahu

PontiMax said:
Eliyahu,

thanks for your reply!

Unfortunately I don't have a clue how to translate your advices into code.
Are there any working examples on the net?
By the way: I've found an older post where you've recommended the use of
hidden fields and javascript event handlers:
Server-side code:
...
e.Item.Attributes["ondblclick"] = "onDblClick(this)";
...

Client-side code:

function onDblClick(row) {
document.getElementById("inpRowId").innerText=row.cells(0).innerText;
document.getElementById("btnEdit").click();
}

Sad to say that this doesn't work for my user control.
"document.getElementById raises an error... :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top