Clicks and double-clicks

Discussion in 'ASP .Net Datagrid Control' started by PontiMax, Jul 14, 2004.

  1. PontiMax

    PontiMax Guest

    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.
     
    PontiMax, Jul 14, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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.
     
    Eliyahu Goldin, Jul 14, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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... :-(
    >
    > Thanks,
    > P.
    >
    >
    >
    > "Eliyahu Goldin" wrote:
    >
    > > 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" <> wrote in message
    > > news:...
    > > > 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.

    > >
    > >
    > >
     
    Eliyahu Goldin, Jul 14, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. da Vinci
    Replies:
    5
    Views:
    8,758
    da Vinci
    Jul 31, 2004
  2. Sydex
    Replies:
    12
    Views:
    6,601
    Victor Bazarov
    Feb 17, 2005
  3. Ingo Nolden
    Replies:
    15
    Views:
    1,543
    Jerry Coffin
    Apr 30, 2005
  4. J.M.
    Replies:
    5
    Views:
    804
  5. Shriramana Sharma
    Replies:
    8
    Views:
    290
    Gerhard Fiedler
    Jun 18, 2013
Loading...

Share This Page