Normally we call onSelectRow function like:
$("#imports_grid").jqGrid({
// jqGrid settings
url: url,
datatype: "json",
colNames: cnames,
colModel: cmodel,
onSelectRow: function() {
// Code
},
});
My PHP script outputs jqGrid settings using json_encode() so it looks like
$script = '$("#imports_grid").jqGrid(' . json_encode($js_settings) . ');';
// echo $script;
In this case, onSelectRow’s function does not work.
Is there an alternative method to fire function inside onSelectRow?
You don’t need to mix HTML code and JavaScript code inside of PHP script. Instead of that you can place
<script>elementin the PHP script. The JavaScript code you can place in the .JS file.
UPDATED: You can make of cause a mix between inline JavaScript code where you set some global variables and the JS file where you use the variables:
in PHP code you use
and in
my.jsyou just useMYGLOBALSETTINGS.cnamesandMYGLOBALSETTINGS.cmodel