Hide detail table tab on condition

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Laim71
User
Posts: 75

Hide detail table tab on condition

Post by Laim71 »

Hello everyone

I wish when I make a choice in a master table by clicking a radio button, then only a corresponding details tab is displayed and the other hidden.

Tables names

  • Master table: “t_stock”
  • input details table: “t_entreestock”
  • output details table: “t_sortiestock”
    The of selection field is named "naturemvtstock".
    I put the code in "Client side events" of the Edit Tag of the field "Naturemvtstock"

This is the code that not work yet.

$(document).ready(function() {
$("input[name='x_naturemvtstock']").change(function(){
if ($("input[name='x_ naturemvtstock ']:checked").val() == 'Entrée stock'){
$('[data-table="t_entreestock"]').show();
$('[data-table="t_sortiestock"]').hide();
}
if ($("input[name='x_ naturemvtstock ']:checked").val() == 'Sortie stock'){
$('[data-table="t_entreestock"]').hide();
$('[data-table="t_sortiestock"]').hide();
}
}
}

Thanks to all


Laim71
User
Posts: 75

Post by Laim71 »

Hi,
I still need help about my concern.

I tried a lot of options but my application does not work as expected.

For remind i like to hide a detail table tab according to a value selected in a field of the master table.

This is my last code placed in Client script > Startup scrip

keys = event types, values = handler functions
"change": function(e) {
if ($this->Naturemvtstock->CurrentValue === "Entrée") {
$this->DetailPages->Items["t_entreestock"]->Visible = TRUE;
$this->DetailPages->Items["t_sortiestock"]->Visible = FALSE;
Else {
$this->DetailPages->Items["t_entreestock"]->Visible = FALSE;
$this->DetailPages->Items["t_sortiestock"]->Visible = TRUE;
}
}

THANKS


arbei
User
Posts: 9383

Post by arbei »

You cannot use PHP code in client side script (JavaScript).

You can add the "client side events" in Edit tag of the radio button, then hide the detail table tab by their id.

For example:
"click": function(e) {
// Your code
if ($(this).val() == "<Value 1>") {
$("#tab<Table1>").show();
$("#tab
<Table2>").hide();
}
}

Read help file topic: "Project Setup" -> "Field Setup" -> "Client side events (for Add/Copy/Edit/Search) " for more information.


Laim71
User
Posts: 75

Post by Laim71 »

I'd just like to thank you again, but I've not still succed.

During around 01 week I tried different codes but they don't work.

This is the last in the field client side event ( I've changed the field edit tag in Select)

keys = event types, values = handler functions
"change": function(e) {
if (($this).fields("Naturemvtstock").value() == "Entrée") {
$("#tab_t_entreestock").show();
$("#tab_ t_sortiestock ").hide();
}
Else {
$("#tab_t_entreestock").hide();
$("#tab_ t_sortiestock ").show();
}
}


The question I have about is how am I sure of the right programming names (Used by PHPMaker V 2017) of objects (Field, Tab).

Bests Regards


arbei
User
Posts: 9383

Post by arbei »

You can use Right Click + Inspect on the Tab and the Tab-Content in order to check the id or class name.

Note that you need to hide/show both the Tab and Tab-Content as the same time, in your code only hide/show the tab-content only. The user still can click on the tab to show the tab-content.


Post Reply