Forum Discussion

jeff_stroh's avatar
jeff_stroh
Ideator I
3 months ago

Targeting Element on Form from Relationship Grid

Hello All,

I'm making a relationship grid event that fires on a row selection.  It's meant to target an HTML control on the top item form and then will fill it with a TGV.

Trouble is, I'm running in circles trying to target the element on the form, which is called 'tgv'.

Lots of debugger tries in the console and methods and nothing is finding it.

Have tried...

top.mainWindow.document.getElementsByName("tgv")[0];
top.mainWindow.document.querySelector('div[name="tgv"]');

parent.document......

Any thoughts or help?

7 Replies

  • I am not sure I understood the use case but I want to give it a try.

    Do you use the custom HTML element as frame for the TGV rendering? So e.g. instead of having the typical  "BOM structure" relationship with the TGV, you show the TGV in your custom element?

    Can you provide a rough screenshot? You can hide the actual data!

    I think you can use the code that is typical used for TGV CUI Actions as basis. The ES Crawler does something similar, but I would have to check first. 

    • jeff_stroh's avatar
      jeff_stroh
      Ideator I

      Hey Angela, sure thing let me give a screen shot (identifiable info blanked out):

      Basically if a user selects a row in the bottom I'm wanting to refresh/re-run the TGV in the top form.  I can get a specific TGV to display in a dialog, but for whatever reason I can't figure out how to target the top form divs by ID or name from the relationship grid method.

      We're more or less looking to invoke sort of a split view wherein we can get additional details and have people do work in the grid at the bottom without extra clicks.

      I'm not 100% certain that this will be the way to go as the onSelect event seems to fire EVERY click on a row which is not ideal (e.g. when you go to edit, it's firing...) so I may need to approach another way, but conceptually this is what we were aiming for.

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        Hey cool, I have tried something like this some time ago, but didn´t use it in the end. 

        Mainly because I wasn´t able to achieve the TGV filtering that I wanted:  link 

        (The post doesn´t mentioned that the TGV was supposed to be part of a Form, but it was the final goal ).

        I still have the concept lying around somewhere and will check if I can find something helpful. But if somebody else has an idea please let us know!

        Do buttons like "Refresh" in your TGV work when you click them manually?

        A simple/stupid solution would maybe be parent.onRefresh(); which should refresh the Form completely. People will love the constant Form refreshes! But I expect it should be possible to address the TGV itself.

        Instead of "onSelect" you can maybe use a right click CUI element or a CUI toolbar button. 

  • The TGV from my POV is not rendered as classic HTML, but is dynamically built. It seems that we cannot access the buttons inside the TGV with "querySelector" or similiar.

    The refresh button is a CUI element and uses following code:
    -> inArgs.contextParams.tgvContext.reload();

    inArgs typcially comes with the CUI call, so it´s empty when we come from something else.Maybe we can use the available function somehow, but I am not sure.

    One simple solution that I have found is, just to reload the frame that is used for the TGV in the Form. But it will reload everything, incl. TGV toolbar:

    const x = document.getElementById('xy');
    x.contentWindow.location.reload();

    • jeff_stroh's avatar
      jeff_stroh
      Ideator I

      Hey Angela, thanks.  I may have not explained correctly.  I'm just trying to sort out how to target the HTML control on the Item form from the relationship grid.  Any combo of the various selects, when fired from the relationship grid, don't seem to be able to find the element by name.

      I believe that the method we have will do what we need it to with the TGV since replaces the iframe contents.  We're using the same approach in a 'two column' form which has two side by side TGVs that update/change out depending upon buttons or actions.

      Does that clarify?

      • AngelaIp's avatar
        AngelaIp
        Ideator I

        Ah I see! You come from the relationship, while I did my tests from a Form button. I don´t have an answer know, but I will check. I am interested in this one too.