0

I'm trying to use the following JavaScript function to get a particular cell value from a jqgrid upon click.

In the below function #datagrid is the table where the jqgrid is stored in.

            $("#datagrid").click(function(){ 
                var selr = $("#datagrid").getCol('companyid');
                alert(selr);
            });

My problem is when I click the jqgrid it will show ALL row id's from the jqgrid in the alert message, but I only need a particular companyid which was selected from the jqgrid. How do I make this work?

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
User
  • 1,644
  • 10
  • 40
  • 64

1 Answers1

1

You should use getCell function to read the value from the cell identified by row id.

So, You should try something like this:

$("#datagrid").click(function(){ 
    var grid = jQuery('#datagrid');
    var sel_id = grid.jqGrid('getGridParam', 'selrow');
    var myCellData = grid.jqGrid('getCell', sel_id, 'MyColName');
});
Ahsan Khurshid
  • 9,383
  • 1
  • 33
  • 51
  • if i click first time on jqgrid it gives false.then i clicked another row ,now i get the row id which is clicked previous row's id – User Sep 03 '12 at 06:29