Hi,
I have a problem when editing a row in a subgrid.
When I click on the edit icon, it opens 2 edit dialogs. One for the row I want and the other for the master row the subgrid belongs.
I am using this code on the master grid:
var opts = {
'ondblClickRow': function (id) {
jQuery("#list1").jqGrid('editGridRow', id, <?php echo json_encode_jsfunc($g1->options["edit_options"])?>);
}
};
I am using this code on the subgrid:
<script type="text/javascript">
var opts = {
'ondblClickRow': function (id) {
var grid_id = <?php echo $property_id;?>;
var grid = $("#_list1_"+grid_id);
jQuery(grid).jqGrid('editGridRow', id, <?php echo json_encode_jsfunc($g->options["edit_options"])?>);
}
};
</script>
it does not work, even specifying what grid I want in the JQuery function.
Any advice? Thanks.
Also, this post did not help me:
Changing the name of grids like: master = list1 and detail = list2 did not help either.
Ideally, the post you later mentioned should work.
You can also try using alternate syntax:
$opt["ondblClickRow"] = "function(id,row,col) { open_dialog(id,row,col); }";
$grid->set_options($opt);
…
<script>
function open_dialog(id,r,c)
{
var grid_id = <?php echo $property_id;?>;
var grid = $("#_list1_"+grid_id);
jQuery(grid).jqGrid('editGridRow', id, <?php echo json_encode_jsfunc($g->options["edit_options"])?>);
}
</script>
Make sure all variables like grid_id contains correct data.
I am sorry, the code you suggested did not solve the problem.
Could you please e-mail me 2 pages as sample where editing a subgrid row does not open the edit dialog master row?
Thanks
E
The issue was, when you double click subgrid, it was invoking event for subgrid as well as master grid (because subgrid was inside master grid's td)
Solution was to stop the event propagation when dblclicked on subgrid row.
<script>
var grid_id = <?php echo $c_id;?>;
var grid = $("#_list1_"+grid_id);
var opts_<?php echo $g->id?> = {
'ondblClickRow': function (id,row,col,e) {
jQuery(grid).jqGrid('editGridRow', id, <?php echo json_encode_jsfunc($g->options["edit_options"])?>);
e.stopImmediatePropagation();
}
};
</script>