Page 1 of 1

SUBFORM - dynamically disable add-delete function

Posted: Wed Sep 18, 2019 2:36 pm
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"
------------------

Re: SUBFORM - dynamically disable add-delete function

Posted: Wed Sep 18, 2019 3:55 pm
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
...

Re: SUBFORM - dynamically disable add-delete function

Posted: Wed Sep 18, 2019 7:03 pm
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);

Re: SUBFORM - dynamically disable add-delete function

Posted: Wed Sep 18, 2019 11:23 pm
by Janusz
Thanks a lot - it's working.

Re: SUBFORM - dynamically disable add-delete function

Posted: Thu Sep 19, 2019 11:16 pm
by admin
.