Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

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

Questions related to using nuBuilder Forte.
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post by Janusz »

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
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

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

Unread post by paulkauz »

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
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post by Janusz »

for that you could try to use hash cookies
https://wiki.nubuilder.cloud/ ... sh_Cookies
and
https://wiki.nubuilder.cloud/ ... 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
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

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

Unread post by paulkauz »

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
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post by Janusz »

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.cloud/ ... ntFlow.PNG
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

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

Unread post by kev1n »

You can also join Discord to discuss (I also speak German). It's way easier...
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

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

Unread post by paulkauz »

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
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

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

Unread post by Janusz »

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
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

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

Unread post by paulkauz »

Yes it works for me as well only with the '1'
If you like nuBuilder, please leave a review on SourceForge
paulkauz
Posts: 30
Joined: Fri Oct 30, 2020 7:08 pm

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

Unread post by paulkauz »

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
Post Reply