7

I have the code below:

$buttonoptions = array("#pager", 
    array(
        "caption" => "Select Product",
        "onClickButton" => "js: function() {
            var selr = jQuery('#grid').jqGrid('getGridParam', 'selrow');
            var kelr = jQuery('#grid').jqGrid('getRowData', 'product_cat_id');
            if(selr) { 
                alert('grid.php?advice=' + selr + kelr); 
            } else {
                alert('Please Select a Product!');
                return false;
            }
        }"
    )
);

I successfully got the row ID in the following way:

var selr = jQuery('#grid').jqGrid('getGridParam','selrow');

But couldn't get the data of the selected row's product_cat_id column.

What is wrong?

Maccath
  • 3,936
  • 4
  • 28
  • 42
dr.linux
  • 752
  • 5
  • 15
  • 37

1 Answers1

15

You use getRowData in a wrong way. Try

var kelr = jQuery('#grid').jqGrid('getCell', selr, 'product_cat_id');

or

var rowData = jQuery('#grid').jqGrid('getRowData', selr);    
var kelr = rowData.product_cat_id;

instead of

var kelr = jQuery('#grid').jqGrid('getRowData','product_cat_id');
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • 2
    Yet another helpful answer by @Oleg. I think it must be that the official jQgrid site is too hard to search / read. I always seem to find what I'm looking for on StackOverflow rather than the jQgrid docs site. – blong Sep 27 '11 at 17:35
  • @Brian L: Thanks! I do my best to help other. You are welcome! – Oleg Sep 27 '11 at 19:00
  • @Oleg: Can take a look at http://stackoverflow.com/questions/14740258/jqgrid-select-checkbox. I am trying to find the best way of doing it. Thanks – Nate Pet Feb 07 '13 at 15:04