我想继承DATAGRID控件,然后想要实现可以用上下光标键选择DATAGRID中的数据行,这个如何做呢,请大家帮个忙
解决方案 »
- 在MVC框架中如何捕获自定义事件?
- url重写实现减掉两个文件夹路径?????期盼大家的帮助!!!
- 50分 求一正则表达式
- 求win2003+IIS6.0 405错误的解决办法
- 如何用javaScript给asp的lable控件赋值并能传递到后台?
- 虚心向各位高手请教如何在2级目录下配置web.config
- 请教大家一个问题,就是怎么样才能在datagrid上显示栏位就像是“仓库别/名称”。。。例如為container.dataitem("depot_code")和container
- 如何去掉select的边框
- repeater绑定分类的问题
- 谁能提供 IE WebControls控件?
- 求教输入用户名和密码后进入一个另邮件系统的问题
- ASP.NET(C#)开发技术群(群号:3248435),大家赶紧加,本群宗旨:代码共享,技术共享。四海之内,皆是朋友。--此信息长期有效,保
<script language="javascript">
var oldrow;
var currowno=-1;
var strReturn; //存储返回值
var newColor='#ffcc66';
var oldColor;
var MaxRowCount;
function SelectOK(text)
{
eval("parent.opener.document.all.TextBox1.value = text");
parent.close();
}
function ChangePage(KeyCode)
{
document.all('DataGrid1').focus();
if ( KeyCode == 33 ) { // 定义 PageUp 键快捷功能
document.all.PrevPage.click();
}
if ( KeyCode == 34 ) { // 定义 PageDown 键快捷功能
document.all.NextPage.click();
}
if ( KeyCode == 36 ) { // 定义 Home 键快捷功能
document.all.FirstPage.click();
}
if ( KeyCode == 35 ) { // 定义 End 键快捷功能
document.all.LastPage.click();
}
if ( KeyCode == 38 ) { // ↑ 键快捷功能
if(currowno==0)//如果已经为第0行,则跳到txtFilter中
{
currowno=-1;//设置未为选中状态
document.all('ROW0').style.backgroundColor=oldColor;
document.all.txtFilter.focus();
}
else
{
MoveUp();
}
}
if ( KeyCode == 40 ) { // ↓ 键快捷功能
if(currowno==-1)//如果还没有选中Grid中的行,则设置Grid的第0行为选中状态
{
if(document.all('ROW0')!=null)
document.all('ROW0').click();
else
document.all.txtFilter.focus();
}
else
{
MoveDown();
}
}
if ( KeyCode == 37 ) { // ← 键快捷功能( 上一层 )
//QueryParent();
}
if ( KeyCode == 39 ) { // → 键快捷功能( 下一层 )
//QueryChild();
}
if ( KeyCode == 13 ) { // 回车键
if(event.srcElement.name=='txtFilter')
{
document.all.LastPage.disabled = true;
document.all.FirstPage.disabled = true;
document.all.PrevPage.disabled = true;
document.all.NextPage.disabled = true;
document.all.GotoPage.disabled = true;
}
else
{
if(currowno!=-1)
{
document.all.LastPage.disabled = true;
document.all.FirstPage.disabled = true;
document.all.PrevPage.disabled = true;
document.all.NextPage.disabled = true;
document.all.btnFilteData.disabled = true;
document.all.GotoPage.disabled = true;
GotoMain(strReturn);
}
}
}
}
function RowFocus(rowno,strValue)
{
if(currowno!=-1){
oldrow.style.backgroundColor=oldColor;
}
strReturn = strValue;
oldColor=document.all('ROW' + rowno).style.backgroundColor;
oldrow=document.all('ROW' + rowno);
document.all('ROW' + rowno).style.backgroundColor= newColor;
currowno=rowno;
}
function MoveUp() {
if(currowno!=-1)
{
if(currowno==0)
currowno=MaxRowCount-1;
else
currowno=currowno-1;
document.all('ROW' + currowno).click();
}
else
document.all.txtFilter.focus();
} function MoveDown() {
if(currowno==MaxRowCount-1)
currowno=0;
else
currowno=currowno+1;
document.all('ROW' + currowno).click();
}
</script>
<script language="JavaScript" event="onkeydown" for="document">
if ( event.keyCode == 34 || event.keyCode == 33 || event.keyCode == 35 || event.keyCode == 36 || event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40 || event.keyCode == 13 )
{
ChangePage(event.keyCode);
}
if ( event.keyCode == 27 )
{
history.go(-1);
} </script>
怎么样?