如何处理 jQuery 网格中的行单击事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2595419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:51:24  来源:igfitidea点击:

How to handle row click event in jQuery grid

jquery

提问by kumar

I have a jQuery grid with data with user data. I need to handle the click on grid row for each grid row when I click I need to display other grid in the bottom of the grid.

我有一个带有用户数据的 jQuery 网格。当我单击需要在网格底部显示其他网格时,我需要处理每个网格行的网格行点击。

Some thing like very similar to this:

有些事情与此非常相似:

http://www.trirand.com/blog/jqgrid/jqgrid.html

http://www.trirand.com/blog/jqgrid/jqgrid.html

Go to Advanced ---> master details

转到高级 ---> 主详细信息

Thanks

谢谢

回答by Glennular

the onSelectRow is what is making the details grid load the information from the master grid.

onSelectRow 是使细节网格从主网格加载信息的原因。

   onSelectRow: function(ids) { 
            if(ids == null) {
                    ids=0; 
                    if(jQuery("#list10_d").jqGrid('getGridParam','records') >0 ) 
                    { 
                        jQuery("#list10_d").jqGrid('setGridParam',{url:"subgrid.php?q=1&id="+ids,page:1});
                        jQuery("#list10_d").jqGrid('setCaption',"Invoice Detail: "+ids) 
                        .trigger('reloadGrid'); 
                    }
                } else { 
                    jQuery("#list10_d").jqGrid('setGridParam',{url:"subgrid.php?q=1&id="+ids,page:1}); 
                    jQuery("#list10_d").jqGrid('setCaption',"Invoice Detail: "+ids)
                    .trigger('reloadGrid');
                } 
        }

回答by Raja

This is how you use it

这就是你如何使用它

$("#tablename tr").click(function(){//do what needs to be done});

HTH

HTH

回答by JenniferWalters

Inside the click event you might need to get the ID of the row. How do you get it?

在 click 事件中,您可能需要获取行的 ID。你怎么得到它?

$("#tblGridMain tr").click(function () {
    var tr = $(this)[0];
    var trID = tr.id;
    alert("trID=" + trID);
});