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