:: Forum >>
Event handler problem in IE
Hello EveryBody,
I am displaying grid and by default i am selecting first row using setSelectedRows([0]) method.Now i am attaching event handlers to the grid using setEvent method.I want to execute some functionality when i press enter in any row of the grid. It is working fine only,we I click on any row and press enter.After loading the grid, if i won't click on the row and if i press enter it is not working.My question is cann't it take the row selected using setSelectedRows([0]) as default row and execute the functionality by pressing enter key.
ie: event handlers are not working without clicking on any row.
I am using the following code for event handlers.
var myKeyEventHandler = function(){
alert();
}
obj.setEvent("onkeydown", myKeyEventHandler);
VaraPrasad
Thursday, July 19, 2007
Hi VaraPrasad,
Please try below code. I have set focus to cellinstead of row.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="tblID">
<tr id="testTd">
<td>test</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<script language="javascript">
var myKeyEventHandler = function(){alert('Hello World');}
document.getElementById('tblID').rows[0].cells[0].focus();
document.getElementById('testTd').onkeydown = myKeyEventHandler;
//alert(document.getElementById('tblID').rows[0].cells[0].focus())
</script>
Regards
Ravi Katre
Ravi Katre
Friday, July 20, 2007
The keyboard events fire only when the control has focus (is activated). Use focus() method after the page is loaded -
grid.focus();
Alex (ActiveWidgets)
Friday, July 20, 2007
Thanks Alex.
When I use grid.focus() it is working fine
VaraPrasad
Monday, July 23, 2007
This topic is archived.
Back to support forum
Forum search