jqgrid getRowData returns null
Asked Answered
T

1

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?

Tilburg answered 24/8, 2011 at 16:46 Comment(0)
L
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');
Lubbi answered 24/8, 2011 at 16:51 Comment(3)
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.Tejeda
@Brian L: Thanks! I do my best to help other. You are welcome!Lubbi
@Oleg: Can take a look at https://mcmap.net/q/1478074/-jqgrid-select-checkbox. I am trying to find the best way of doing it. ThanksSuperfuse

© 2022 - 2024 — McMap. All rights reserved.