Page 1 of 1
nuSelectBrowse opening nuUserhome?
Posted: Mon Oct 05, 2020 10:03 pm
by benritter
Hello,
I'm trying to use the nuSelectBrowse function. When I click on a record in a browse form (which is displayed in an iframe) I want it to open the edit form, filled with values from the browse form. I am using this code in the JavaScript of the browse form.
function nuSelectBrowse(e){
var r = $('#' + e.target.id).attr('data-nu-primary-key');
nuForm(nuGetProperty('client_id'), '-1', '', '', '0');
}
'client_id' is the PK of my form.
With this code, When I click on a record in the browse form, It opens the nuUserhome launch form.
I suspect that I am using the wrong values in the 'form_id' and 'record_id' places.
I have also tried eliminating the middle line of code so it's just a nuForm inside the nuSelectBrowse, and I get the same result. Any ideas?
Thanks.
Re: nuSelectBrowse opening nuUserhome?
Posted: Mon Oct 05, 2020 10:23 pm
by Janusz
Hi,
The first parameter of nuForm is the form ID - originally it's nuGetProperty('form_id')
if you want to redirect to any other form you have to indicate other form ID.
e.g. nuForm("5c23e11c067a524",a,'', '');
and following can be helpfull:
https://forums.nubuilder.cloud/viewtopic. ... led#p18553
Re: nuSelectBrowse opening nuUserhome?
Posted: Mon Oct 05, 2020 10:56 pm
by benritter
Thanks!
I got the proper 'form_id' using f12 and placed it in where nuGetProperty was. And now clicking on a browse form row opens the edit form.
Is there a way to fill the edit form with all the saved values in the table based on the PK of the selection in the browse form?
Re: nuSelectBrowse opening nuUserhome?
Posted: Mon Oct 05, 2020 11:09 pm
by benritter
maybe with nuGetLookupId('my_form_id', 'object id from edit form'); ?
Even if I had to manually do a nuLookupId for each object, that would be doable.
Re: nuSelectBrowse opening nuUserhome?
Posted: Mon Oct 05, 2020 11:54 pm
by Janusz
not sure if I properly understand the subject
I assume that from one browse form you want to open other edit form
(in case of the same browse/edit form you have direct access to all table values both in browse and edit form)
so if you want to go to other edit form you can first read the values of the browse form from selected record for example:
Code: Select all
function nuSelectBrowse(e){
var row = $('#' + e.target.id).attr('data-nu-row');
var col0 = $('#nucell_' + row + "_" + 0).html();
var col1 = $('#nucell_' + row + "_" + 1).html();
var col2 = $('#nucell_' + row + "_" + 2).html();
console.log(row,col0,col1,col2);
}
(and you can check the values in the console)
next you can set the the session storage items, open new edit form, and set the stored values to the specific fields as in the
https://forums.nubuilder.cloud/viewtopic. ... led#p18553
Re: nuSelectBrowse opening nuUserhome?
Posted: Tue Oct 06, 2020 4:20 pm
by benritter
I did have separate browse and edit forms accessing the same table. I just changed the form running in my browse iframe to the same form as the edit form. Now it works. Thank you.
Re: nuSelectBrowse opening nuUserhome?
Posted: Tue Oct 06, 2020 8:25 pm
by benritter
I am having a new issue now. I keep getting the message:
fatal error.png
After changing my edit only form and subform to browse and edit, I deleted the old browse only forms. Maybe that's what caused it?
It seems like an infinite loop. How do I find where the code is bad?
Re: nuSelectBrowse opening nuUserhome?
Posted: Tue Oct 06, 2020 10:17 pm
by benritter
I fixed this. I had a join in the browse SQL of the old browse only form. like this:
SELECT
*
FROM
(
SELECT
household.*,
client.client_number
FROM
household
LEFT JOIN client ON household.client_id = client.client_id
) T
so that I could search subform entries based on the parent form id. When I deleted the old browse only, I think that created a data loop when it was trying to make the connection.
Re: nuSelectBrowse opening nuUserhome?
Posted: Sun Oct 11, 2020 10:30 pm
by admin
well done.