Subform row id - hash cookie

Subform row id - hash cookie

Postby tovidiu » Sun Jan 07, 2018 2:47 am

I'm trying to create a button that opens the record from another table to be edited but I can not do it because I do not know the record_id of the row from the subform to insert it into the filter field.
The field "Nr Top" holds the id field of "Parcele extravilan" form, i put the id field in the browse of "Parcele extravilan"

What am I doing wrong?
THX
Attachments
ex 1.png
Subform
ex 1.png (7.29 KiB) Viewed 98 times
ex 2.png
filter field
ex 2.png (4.32 KiB) Viewed 98 times
ex 3.png
result with emty table
ex 3.png (9.78 KiB) Viewed 98 times
tovidiu
 
Posts: 7
Joined: Sun Jan 07, 2018 2:15 am

Re: Subform row id - hash cookie

Postby admin » Sun Jan 07, 2018 3:18 am

tovidiu,

Great question.

Instead of using a Run Object, use an Input Object and set its Type to Button (they should still look the same).

Add an onclick Event via its Custom Code Tab with the following Javascript.

Code: Select all
nuPopup('aaaa', nuSubformRowId(this));           //-- make aaaa the id of the Form you would like to open


Here is some help in the wiki ...

http://wiki.nubuilder.net/nubuilderforte/index.php/Objects#Tab_-_Input

http://wiki.nubuilder.net/nubuilderforte/index.php/Javascript#nuPopup

http://wiki.nubuilder.net/nubuilderforte/index.php/Javascript#nuSubformRowId


Steven
admin
Site Admin
 
Posts: 2053
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform row id - hash cookie

Postby tovidiu » Sun Jan 07, 2018 5:40 am

Thanks for the reply,
I did as you said but it does not work, nothing happens when I click on the button.
this is the code
Code: Select all
nuPopup('5a29ddbd60e1aa9', nuSubformRowId(this));


I modified the code according to the parameters "noPopup (string1, string2, string3)" as follows
Code: Select all
nuPopup('5a29ddbd60e1aa9', '', nuSubformRowId(this));

but it still does not work.

in this version should open the form '5a29ddbd60e1aa9' as browse with filter nuSubformRowId(this), but stil nothing happens. As if it did not read the row id of the subform.


it is possible to use the following code? I want to use the lookup field not the subform row id, because like this it will open up directly in Edit form
Code: Select all
nuPopup('5a29ddbd60e1aa9','lookup_field');


Ovidiu
tovidiu
 
Posts: 7
Joined: Sun Jan 07, 2018 2:15 am

Re: Subform row id - hash cookie

Postby admin » Sun Jan 07, 2018 6:14 am

Ovidiu,

You will need the lastest from github because I just added nuSubformRowId().

If you want the value from a Lookup or other Object try...

Code: Select all
nuSubformValue(this, 'ite_product_id');



Steven
admin
Site Admin
 
Posts: 2053
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform row id - hash cookie

Postby tovidiu » Sun Jan 07, 2018 6:37 am

It works perfectly!

Thank you very much Steven!

Ovidiu
tovidiu
 
Posts: 7
Joined: Sun Jan 07, 2018 2:15 am

Re: Subform row id - hash cookie

Postby tovidiu » Sun Jan 07, 2018 7:20 am

And if I have the same case but the lookup object and the button are in form not subform, how can i read the lookup value to use it in Javascript?

for example:
Code: Select all
nuPopup('5a29ddbd60e1aa9', nuFormValue(this, 'lookup_field'));


Ovidiu
tovidiu
 
Posts: 7
Joined: Sun Jan 07, 2018 2:15 am

Re: Subform row id - hash cookie

Postby admin » Sun Jan 07, 2018 7:27 am

Ovidiu,

If your Object is on an Edit Form, you can get the value this way...

Code: Select all
var v = $('#lookup_field_id').val();               //-- the Object's ID prefixed by a #


Here are other ways you can use this $() jQuery function... https://www.w3schools.com/jquery/jquery_ref_selectors.asp

Steven
admin
Site Admin
 
Posts: 2053
Joined: Mon Jun 15, 2009 9:53 am

Re: Subform row id - hash cookie

Postby tovidiu » Sun Jan 07, 2018 7:43 am

Thank you, it works!!

Ovidiu
tovidiu
 
Posts: 7
Joined: Sun Jan 07, 2018 2:15 am

Re: Subform row id - hash cookie

Postby admin » Sun Jan 07, 2018 8:30 am

.
admin
Site Admin
 
Posts: 2053
Joined: Mon Jun 15, 2009 9:53 am


Return to General