Hi I would like to know if it is possible to use cascade select in a subform. subform displayed in edit mode.
how can i move the label above the object
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Cascade select in subform
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Cascade select in subform
Hi,
There's an example somewhere in the forum for a subform in Grid mode. I haven't tried that approach for Type "Form".
There's an example somewhere in the forum for a subform in Grid mode. I haven't tried that approach for Type "Form".
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Cascade select in subform
hi, i found the post you are talking about and i am trying that solution https://forums.nubuilder.cloud/viewtopic.php?t=11249
I managed to get it working by adapting the code to my app's field names but I have a problem when I open a record that already has lines filled in the subform. Both the first and second select show the previously saved data but if I try to change the value of the second select without changing the first I get the complete list and not the data related to the first select. instead I modify first select and then the second everything works. in the picture ignore the lookup icon is not used...
this is the main form code
this is sql from the second select
this is the onChange event of the first select
Where am I doing wrong?
I managed to get it working by adapting the code to my app's field names but I have a problem when I open a record that already has lines filled in the subform. Both the first and second select show the previously saved data but if I try to change the value of the second select without changing the first I get the complete list and not the data related to the first select. instead I modify first select and then the second everything works. in the picture ignore the lookup icon is not used...
this is the main form code
Code: Select all
function nuSubformRefreshSelectObject(prefix, selectId, formId, removeBlank) {
if (typeof formId === 'undefined') {
var formId = '';
}
nuSetProperty('nurefreshselectobject_prefix',prefix);
nuSetProperty('nurefreshselectobject_selectid',selectId);
nuSetProperty('nurefreshselectobject_formid',formId);
nuSetProperty('nurefreshselectobject_removeblank',removeBlank === true ? '1' : '0');
nuRunPHPHidden('nurefreshselectobject', 0);
}
function nuSubformPrefix(t, id){
return $(t).attr('data-nu-prefix');
}
function pne_marcaOnChanged(t) {
nuSetProperty('VALUE_SELECT1',nuSubformValue(t, 'pne_marca'));
nuSubformRefreshSelectObject(nuSubformPrefix(t, 'pne_marca'), 'pne_modello', '64d287f80aea206'); // <---- Replace with the the subform's primary key (15-characters unique id)
let pne_modello = t.id.replace('pne_marca','pne_modello');
$('#'+ pne_modello).nuEnable();
}
$('[id^=Sf_pneumatici][id$=pne_modello]').each(function(i,v){ // <---- replace 'subform' with the object id of your subform
$(this).attr('data-value', this.value);
});
$('[id^=Sf_pneumatici][id $=pne_marca]').each(function(i,v){ // <---- replace 'subform' with the object id of your subform
pne_marcaOnChanged(this)
});
function nuBeforeSave() {
nuSetProperty('VALUE_SELECT1','##');
return true;
}
function nuSelectObjectRefreshed(formId, selectId, count) {
let pne_modello = selectId.replace('pne_marca','pne_modello');
$('#'+ pne_modello).val($('#' + pne_modello).attr('data-value'));
}
Code: Select all
SELECT
t_modelli.mod_modello,t_modelli.mod_modello
FROM
t_modelli
JOIN t_marche ON t_modelli.mod_id_marca = t_marche.mar_id
WHERE
(t_marche.mar_marca = '#VALUE_SELECT1#' OR '#VALUE_SELECT1#' LIKE '#%' );
Code: Select all
pne_marcaOnChanged(this);
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 58
- Joined: Mon Sep 09, 2019 8:20 am
Re: Cascade select in subform
hello, ok, I have to finish my webapp and for the moment I have opted for a lookup that takes data from 2 different tables and fills in the two fields of the subform.