Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

SUBFORM - dynamically disable add-delete function

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

SUBFORM - dynamically disable add-delete function

Unread post by Janusz »

Hi,
Depanding on a field value on the main form I want to disable the ADD and Delete function of the subform.
(to hide or disable the checkboxes in the subform and remove the new line to add record)

Was trying for example with
nuSetProperty('data-nu-add',"0");
nuSetProperty('data-nu-delete',"0");
nuHide('nuSubformCheckbox');

but did not succeed :-(

Do you have idea how can I do it?

------------------
Main form:
data-nu-table="parts"
data-nu-form-id="5d5d89dc6a47f23"

Subform:
id="sub_FF_parts"
data-nu-object-id="5d5d8edbbc4c72b"
------------------
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: SUBFORM - dynamically disable add-delete function

Unread post by Janusz »

in the meantime I found solution in the:
https://forums.nubuilder.cloud/viewtopic. ... ble#p17713

Code: Select all

function disableSubformRows(f) {
   // disable all fields of the subform grid
   $('[id ^=' + f + ']').prop("disabled", true);
   // enable the last row to allow new insertions
   var r = nuPad3(nuSubformObject(f).rows.length - 1);
   $('[id ^=' + f + r + ']').prop("disabled", false);
}
but still I want to leave a buton/object on the subform not disabled:

buttons on the subform has following names:
sub_FF_parts001but_location_run

how to place such objects in the following code:

Code: Select all

   $('[id ^=' + f + ???+ 'but_location_run]').prop("disabled", false);     ?????
equivalent to enable back all objects like:
sub_FF_parts000but_location_run
sub_FF_parts001but_location_run
...
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4416
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:

Re: SUBFORM - dynamically disable add-delete function

Unread post by kev1n »

id starts with sub_FF_part and ends with but_location_run:

Code: Select all

$('[id^=sub_FF_parts][id$=but_location_run]').prop("disabled", false);
Janusz
nuBuilder Team
Posts: 508
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 10 times
Been thanked: 18 times

Re: SUBFORM - dynamically disable add-delete function

Unread post by Janusz »

Thanks a lot - it's working.
If you like nuBuilder, please leave a review on SourceForge
admin
Site Admin
Posts: 2822
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 29 times

Re: SUBFORM - dynamically disable add-delete function

Unread post by admin »

.
Post Reply