Welcome to the nuBuilder Forums!

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

How to programmatically clear a table on a subform.

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

How to programmatically clear a table on a subform.

Unread post by kknm »

On the main form there is a button in PHP for filling out the main table. Based on this table, jscript is connected to fill out different tables on the subforms of the main form.
If the result is incorrect, you have to clear the main table and several subordinate tables.
The tables have checkboxes to delete a row, but deleting one row at a time is not practical. I would like one button.
I tried to delete rows based on a certain criterion in PHP, but this was also unproductive.
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: How to programmatically clear a table on a subform.

Unread post by steven »

Hi kknm,

If you use JavaScript you can tick all Subform records to be deleted when you save the record next.

This function will tick all the Delete boxes on a Subform.

subform('task_sf');

Code: Select all

function tick_subform(s){

    $( "[id|='" + s + "'], [id$='nuDelete']" ).prop('checked', 'checked');
    
}
ticks.png

Steven
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kknm »

When placing this code on the main form -
the function marks all Checkboxes on all subforms.

How to make a selection for one subform on the main form?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kev1n »

Try:

Code: Select all

function tickSubform(formId){
    $(`[id^='${formId}'][id$='nuDelete']`).prop('checked', 'checked');
}
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kknm »

It seems to me that there is a typo in the formula - an incomprehensible symbol after id - Chr(94)?
The absence of a comma, which is in the first formula.

I tried to put signs as in the first formula, getting nuFormId('sub_vup') - all subforms are marked.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kev1n »

I tested my function in the Access Levels form and it works fine. (Latest Chrome, Firefox, Edge)

Code: Select all

function tickSubform(formId){
    $(`[id^='${formId}'][id$='nuDelete']`).prop('checked', 'checked');
}


tickSubform('accform');
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kknm »

All my subforms are of GRID type.

Maybe I'm defining formId incorrectly, because with the first formula all subforms (GRID) are marked.

How to get the formId of the desired subform from the main form?
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kev1n »

Select 'Subform Object' from the subform options menu.
You do not have the required permissions to view the files attached to this post.
kknm
Posts: 366
Joined: Sat Apr 11, 2020 12:03 am
Has thanked: 3 times
Been thanked: 4 times
Contact:

Re: How to programmatically clear a table on a subform.

Unread post by kknm »

Thanks, I figured it out!
I incorrectly used object_id instead of subform id.
Post Reply