nuSelectBrowse opening nuUserhome?

Questions related to customising nuBuilder Forte with Javascript or PHP.

nuSelectBrowse opening nuUserhome?

Postby benritter » Tue Oct 06, 2020 5:33 am

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.
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby Janusz » Tue Oct 06, 2020 5:53 am

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:
viewtopic.php?f=20&t=9770&p=18553&hilit=prefilled#p18553
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 358
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: nuSelectBrowse opening nuUserhome?

Postby benritter » Tue Oct 06, 2020 6:26 am

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?
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby benritter » Tue Oct 06, 2020 6:39 am

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.
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby Janusz » Tue Oct 06, 2020 7:24 am

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
viewtopic.php?f=20&t=9770&p=18553&hilit=prefilled#p18553
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 358
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: nuSelectBrowse opening nuUserhome?

Postby benritter » Tue Oct 06, 2020 11:50 pm

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.
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby benritter » Wed Oct 07, 2020 3:55 am

I am having a new issue now. I keep getting the message:
fatal error.png
fatal error.png (6.89 KiB) Viewed 72 times

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?
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby benritter » Wed Oct 07, 2020 5:47 am

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.
benritter
 
Posts: 33
Joined: Thu Aug 27, 2020 6:08 am

Re: nuSelectBrowse opening nuUserhome?

Postby admin » Mon Oct 12, 2020 6:00 am

well done.
admin
Site Admin
 
Posts: 3372
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code



cron