How to handle row click event in jQuery grid
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 o开发者_运维问答ther grid in the bottom of the grid.
Some thing like very similar to this:
http://www.trirand.com/blog/jqgrid/jqgrid.html
Go to Advanced ---> master details
Thanks
the onSelectRow is what is making the details grid load the information from the master grid.
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');
}
}
This is how you use it
$("#tablename tr").click(function(){//do what needs to be done});
HTH
Inside the click event you might need to get the ID of the row. How do you get it?
$("#tblGridMain tr").click(function () {
var tr = $(this)[0];
var trID = tr.id;
alert("trID=" + trID);
});
精彩评论