0
我試圖允許在jqGrid行中向上/向下鍵並觸發文檔點擊功能,但我的調用方法無法正常工作。此代碼:
$("#table_list_1").on("keyup", "tr", function(e)
{
// $("#table_list_1").unbindKeys(e);
//$("#table_list_1").bindKeys(e);
if(e.keyCode == 38 || e.keyCode == 40) //up/down arrow override
{
var gridArr = $('#table_list_1').getDataIDs();
var selrow = $('#table_list_1').getGridParam("selrow");
var curr_index = 0;
for(var i = 0; i < gridArr.length; i++)
{
if(gridArr[i]==selrow)
curr_index = i;
}
if(e.keyCode == 38) //up
{
if((curr_index-1)>=0)
$('#table_list_1').resetSelection().setSelection(gridArr[curr_index-1],true);
}
if(e.keyCode == 40) //down
{
if((curr_index+1)<gridArr.length)
$('#table_list_1').resetSelection().setSelection(gridArr[curr_index+1],true);
}
// $(document).on('click', '#table_list_1 tr');
//$('#table_list_1 tr').click();
//$('#table_list_1tr').jqGrid('setSelection',curr_index+1,true)
//var c = jQuery.Event("click");
//$(document).trigger(c);
$('#table_list_1 tr').trigger('click'); //any of these does not working right.
}
});
像這樣,我嘗試了各種調用方法。這是點擊文件:
try {
$(document).on('click', '#table_list_1 tr', function (e) {
alert();
var id = $(this).find('td:nth-child(1)').text();
var lastname = $(this).find('td:nth-child(2)').text();
var firstname = $(this).find('td:nth-child(3)').text();
document.getElementById("urunad").value = firstname;
// alert(id); code goes on...
我無法正確工作。你有什麼想法,我哪裏錯了?