kumar
kumar

Reputation: 2944

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 other 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

Upvotes: 3

Views: 43899

Answers (3)

JenniferWalters
JenniferWalters

Reputation: 87

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);
});

Upvotes: 1

Glennular
Glennular

Reputation: 18215

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');
                } 
        }

Upvotes: 5

Raja
Raja

Reputation: 3618

This is how you use it

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

HTH

Upvotes: 1

Related Questions