Change options like hiddengrid on the fly

QuestionsChange options like hiddengrid on the fly
Glenn asked 4 years ago

Is it possible to change the hiddengrid options value of a detail grid depending on values in a mastergrid? So if groupid value = 0 have the detail grid hidden otherwise show it.
Thanks

6 Answers
Abu Ghufran answered 4 years ago

In mastergrid, you need to connect onSelectRow event: (where list1 is master grid, list2 is detail)

$opt["onSelectRow"] = "function(id){ var gid = jQuery('#list1').jqGrid('getCell', id, 'groupid'); if (gid == 0) $("#list2").jqGrid('setGridState', 'hidden'); else $("#list2").jqGrid('setGridState', 'visible'); }";

$g->set_options($opt);

Glenn answered 4 years ago

Thanks Abu,

Unfortunately, that had no effect.
To test it I also updated your master-detail.php demo with the line below.
http://websalesdesign.com/proj/lib/phpgrid-full/index.php

$opt["onSelectRow"] = "function(id){ var gid = jQuery('#list1').jqGrid('getCell', id, 'gender'); if (gid == 'male') $('#list2').jqGrid('setGridState', 'hidden'); else $('#list2').jqGrid('setGridState', 'visible'); }";

Regards,
Glenn

Abu Ghufran answered 4 years ago

Hello,

line 28: Move onSelectRow with master grid options (from detail grid)
Code: http://hastebin.com/fahefihuwi.php

Glenn answered 4 years ago

Hi Abu,

I tried what you suggested and it had no effect.
Did you get this code working on your end?

Abu Ghufran answered 4 years ago

Yes, it was working.

I've emailed you latest build, try after that update.

Glenn answered 4 years ago

Thanks Abu
Your update solved it.

Your Answer

7 + 3 =

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 / 5. Vote count:

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

Let us improve this post!