Highlight Row with Up/Down Arrow

A

Alan Z. Scharf

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
 
T

Thiruppathi S

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
 
A

Alan Z. Scharf

Thanks very much for your reply.

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

Regards,

Alan


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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top