Jump from a browse form to a filtered browse and edit form

Questions related to using nuBuilder Forte.

Re: Jump from a browse form to a filtered browse and edit fo

Postby Janusz » Tue Nov 17, 2020 4:13 am

Hi,
What I saw on picture, but it's quite limited info and maybe I am not right - I would think about some structure change.
In the PSP Plannung Massnahmenliste you have
Proj ID and Projectnummer - are they equivalent?
If yes I would NOT use Proj ID in Browse or Edit form at all - use just only Projectnummer - and link all Forms with Projectnummer (e.g. 6-10-000174) - then form linking will be very easy.
Do you use auto increment for the Proj ID?

How can I use the value of the r.attr('data-nu-primary-key') in the select statement of the form "5faebeae9db455f"

you can use directly as you placed in the code, but your Proj ID is something like 1,2,3, - and in such case filter with just 1 will not be good - and probably 99% of records will be selected.
If you would have Proj ID as varchar() with id like 5faebeae9db455f then it would be easy.
But if possible I would just stick to Projectnummer.

Maybe you can try completely other solutions with hash cookies for example - but I have limited experience how it behaves between different forms.
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Jump from a browse form to a filtered browse and edit fo

Postby paulkauz » Tue Nov 17, 2020 6:43 am

Code: Select all
SELECT
    tamassnahmenpsp.*

FROM
    tamassnahmenpsp

WHERE tamassnahmenpsp.PSP_MassnID = ???


What i have in mind is to bring the value of r.attr('data-nu-primary-key') to the sql statement
If for example the MassnID = 6, then it should bring all the records in the Table tamassnahmenpsp wit the PSP_MassnID = 6
Its a normal one to many relation.
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: Jump from a browse form to a filtered browse and edit fo

Postby Janusz » Tue Nov 17, 2020 7:21 am

for that you could try to use hash cookies
https://wiki.nubuilder.net/nubuilderfor ... sh_Cookies
and
https://wiki.nubuilder.net/nubuilderfor ... etProperty

but the issue I had during quick try was that the hash cookie defined in one form was not visible in the other - but it was just a quick try so maybe there is some possibility anyway.

between different forms on js level you can exchange data with session storage:
Code: Select all
sessionStorage.setItem('Proj_ID',r.attr('data-nu-primary-key')); // save data on first form
var  Proj_ID = sessionStorage.getItem('Proj_ID'); // get data on second form
sessionStorage.removeItem('Proj_ID');  // remove data
on second form you can try set set hash cookies with
Code: Select all
nuSetProperty('Proj_ID', Proj_ID)

and in Browse SQL use:
Code: Select all
....
WHERE PSP_MassnID='#Proj_ID#'    or something like that
...

just idea not tested at all
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Jump from a browse form to a filtered browse and edit fo

Postby paulkauz » Wed Nov 18, 2020 7:27 am

Code: Select all
sessionStorage.setItem('Proj_ID',26); // save data on first form
var Proj_ID = sessionStorage.getItem('Proj_ID'); // get data on second form

function nuSelectBrowse(e){
var r = $('#' + e.target.id);
nuForm("5faebeae9db455f", '', '', '' , '0');
}


Problem 1
With this code I can see on the form 5faebeae9db455f the Proj_ID = 26
If I put in the r.attr('data-nu-Primary-key') into the code I get an error

Problem 2
I see on the console Proj_ID = "26" but the select statement
Code: Select all
SELECT
    tamassnahmenpsp.*

FROM
    tamassnahmenpsp

WHERE tamassnahmenpsp.MassnID = #Proj_ID#


does not work. Is this because it transfers a string and the mysql db expects an int ? or do I have a misspelling somewhere in the statement.
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: Jump from a browse form to a filtered browse and edit fo

Postby Janusz » Wed Nov 18, 2020 5:01 pm

hash cookies has to be between apostrophe
Code: Select all
WHERE PSP_MassnID='#Proj_ID#'

I would tranfers all data as txt so: sessionStorage.setItem('Proj_ID','26'); - not sure if manadatory but probably would do like that.

And one more point - after new form is open and is empty - try to refresh (CTRL+SHIFT+R) - I noticed someting like one step delay once making some quick trial.

you can try to analyse as well event flow if it is suppoused to work properly:
https://wiki.nubuilder.net/nubuilderfor ... ntFlow.PNG
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Jump from a browse form to a filtered browse and edit fo

Postby kev1n » Wed Nov 18, 2020 6:42 pm

You can also join Discord to discuss (I also speak German). It's way easier...
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: Jump from a browse form to a filtered browse and edit fo

Postby paulkauz » Thu Nov 19, 2020 12:45 am

The solution!

First Form
CUSTOM CODE

function nuSelectBrowse(e) {

var pk = $(e.target).attr('data-nu-primary-key');
nuSetProperty('pk',pk)
nuForm('5faebeae9db455f', '','' , '', '1');

return false;
}


Second Form
BROWSE

SELECT
tamassnahmenpsp.*

FROM
tamassnahmenpsp

WHERE tamassnahmenpsp.MassnID=#pk#

Thanks to all, helping me to find this solution
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: Jump from a browse form to a filtered browse and edit fo

Postby Janusz » Thu Nov 19, 2020 4:05 am

So great if it's OK :-)

I was a little bit curious - as before I was testing this - and it was not working - so did some more test.

Code: Select all
so this solution works OK with:
nuForm('5c23e11c067a524', '','' , '', '1');

but it does not work with:
nuForm('5c23e11c067a524', '','' , '', '0');
or
nuForm('5c23e11c067a524', '','' , '', '2');


do you have similar behavior on your application?
If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Jump from a browse form to a filtered browse and edit fo

Postby paulkauz » Thu Nov 19, 2020 4:59 am

Yes it works for me as well only with the '1'
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Re: Jump from a browse form to a filtered browse and edit fo

Postby paulkauz » Thu Nov 19, 2020 5:12 am

an other solution:

First Form
CUSTOM CODE

function nuSelectBrowse(e) {

var pk = $(e.target).attr('data-nu-primary-key');
nuSetProperty('pk',pk)
window.nuFORM.setProperty('page_number', 0);
nuForm('5faebeae9db455f', '','' , '', '1');

return false;
}


Second Form
BROWSE

SELECT
tamassnahmenpsp.*

FROM
tamassnahmenpsp

WHERE tamassnahmenpsp.MassnID=#pk#
If you like nuBuilder, please leave a review on SourceForge
paulkauz
 
Posts: 27
Joined: Sat Oct 31, 2020 3:38 am

Previous

Return to General