Dialog edit in sub grid row is also opening the dialog edit in the master grid

QuestionsDialog edit in sub grid row is also opening the dialog edit in the master grid
E Mello asked 9 years ago

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.

5 Answers
E Mello answered 9 years ago

Also, this post did not help me:

https://phpgrid.desk.com/customer/portal/questions/14621750-double-click-the-subgrid-opens-2-edit-dialogs-master-and-subgrid

Changing the name of grids like: master = list1 and detail = list2 did not help either.

Abu Ghufran answered 9 years ago

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.

E Mello answered 9 years ago

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

Abu Ghufran answered 9 years ago

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>

E Mello answered 9 years ago

Thanks very much Abu, problem is now solved.

Your Answer

15 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?