Highlight Row with Up/Down Arrow

Discussion in 'ASP .Net Datagrid Control' started by Alan Z. Scharf, Jul 6, 2005.

  1. I would like to highlight a datagrid row with the up/down movement of the
    arrow keys.

    I already have row highlight working with MouseOver.

    Is there also a way to get highlighting to respond to an up/down event.

    I have not been able to find anything on this via Google.

    Thanks for any advice..

    Alan
    Alan Z. Scharf, Jul 6, 2005
    #1
    1. Advertising

  2. Hi Alan,

    This can be done with help of javascript.

    First add onkeydown,onfocus,onblur event for the DataItem(Table Row) of Datagrid in the ItemCreated event.

    e.Item.Attributes.Add("onfocus", "onMover(this)")
    e.Item.Attributes.Add("onblur", "onMout(this)")
    e.Item.Attributes.Add("tabIndex", e.Item.ItemIndex + 1)
    e.Item.Attributes.Add("ATOMICSELECTION", True)
    e.Item.Attributes.Add("onkeydown", "dg_keydown(this)")


    And in the keydown event,

    function dg_keydown(this)
    {
    if (event.keyCode==40)
    this.parentElement.rows(this.rowIndex+1).focus();
    else if (event.keyCode==38)
    this.parentElement.rows(this.rowIndex-1).focus();
    }

    please note that u hav check the row limit in the above function.
    And in the onfocus and onblur event , change the style so that the Rows will be highlighted.

    Hope this will help You.

    Rgds,

    Thiruppathi S
    Thiruppathi S, Jul 9, 2005
    #2
    1. Advertising

  3. Thanks very much for your reply.

    I will try to work through this and will let you know how it goes.

    Regards,

    Alan


    "Thiruppathi S" <> wrote in message
    news:#...
    Hi Alan,

    This can be done with help of javascript.

    First add onkeydown,onfocus,onblur event for the DataItem(Table Row) of
    Datagrid in the ItemCreated event.

    e.Item.Attributes.Add("onfocus", "onMover(this)")
    e.Item.Attributes.Add("onblur", "onMout(this)")
    e.Item.Attributes.Add("tabIndex", e.Item.ItemIndex + 1)
    e.Item.Attributes.Add("ATOMICSELECTION", True)
    e.Item.Attributes.Add("onkeydown", "dg_keydown(this)")


    And in the keydown event,

    function dg_keydown(this)
    {
    if (event.keyCode==40)
    this.parentElement.rows(this.rowIndex+1).focus();
    else if (event.keyCode==38)
    this.parentElement.rows(this.rowIndex-1).focus();
    }

    please note that u hav check the row limit in the above function.
    And in the onfocus and onblur event , change the style so that the Rows will
    be highlighted.

    Hope this will help You.

    Rgds,

    Thiruppathi S
    Alan Z. Scharf, Jul 9, 2005
    #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. Fernando Lopes
    Replies:
    0
    Views:
    3,177
    Fernando Lopes
    Apr 28, 2005
  2. kurt sune
    Replies:
    1
    Views:
    1,635
    =?Utf-8?B?SmFjZWsgU3Rhd2lja2k=?=
    Jul 29, 2005
  3. dungping
    Replies:
    9
    Views:
    42,337
    Jukka K. Korpela
    Sep 8, 2005
  4. sauce
    Replies:
    0
    Views:
    219
    sauce
    Apr 12, 2005
  5. lorenzo

    highlight row with arrow key

    lorenzo, Nov 10, 2004, in forum: Javascript
    Replies:
    1
    Views:
    98
    McKirahan
    Nov 10, 2004
Loading...

Share This Page