jqgrid getRowData returns null

2019-03-16 14:25发布

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?

1条回答
祖国的老花朵
2楼-- · 2019-03-16 15:13

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');
查看更多
登录 后发表回答