Page 1 of 1
How to programmatically clear a table on a subform.
Posted: Fri Sep 20, 2024 8:52 am
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.
Re: How to programmatically clear a table on a subform.
Posted: Mon Sep 23, 2024 8:32 pm
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
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 7:23 am
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?
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 9:15 am
by kev1n
Try:
Code: Select all
function tickSubform(formId){
$(`[id^='${formId}'][id$='nuDelete']`).prop('checked', 'checked');
}
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 10:17 am
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.
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 10:25 am
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');
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 10:52 am
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?
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 11:23 am
by kev1n
Select 'Subform Object' from the subform options menu.
Re: How to programmatically clear a table on a subform.
Posted: Tue Sep 24, 2024 12:22 pm
by kknm
Thanks, I figured it out!
I incorrectly used object_id instead of subform id.