Alpha Video Training
Results 1 to 8 of 8

Thread: Trouble getting reference to parent grid field

  1. #1
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Trouble getting reference to parent grid field

    Hi,
    I am launching a dialog from a toolbar action button on a grid.
    The dialog has an argument called admid

    I need to set the value of the argument (at runtime) to a field value (AdmissionID) from the parent grid. My parent grid is a Form style grid and only shows one record. I believe I can set an argument's value to a JS Function so I've defined this one but it isn't working so I must have some syntax wrong... any ideas?

    function getadmid() {

    var ParentGrid={grid.Object}.getParentObject();
    if(ParentGrid)
    {
    var myadmid = ParentGrid.getValue('G','ADMISSIONID'ParentGrid.rowNumber);
    return getadmid;
    }
    }

  2. #2
    "Certified" Alphaholic mmaisterrena's Avatar
    Real Name
    Mauricio Maisterrena
    Join Date
    Nov 2006
    Location
    Torreon, Mexico
    Posts
    1,435

    Default Re: Trouble getting reference to parent grid field

    I think this can be achived using the linked option on the open grid js action
    Cheers
    Mauricio


  3. #3
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Re: Trouble getting reference to parent grid field

    Thanks for the reply Mauricio but I'm launching a Dialog, not a grid and you don't appear to be able to link fields like you do when linking grid - grid.

    So as far as I can tell I need to pass the value to the dialog via an argument. My problem is that if the grid that I am launching the dialog from has no records in it (and I've bound the argument to a field in this grid) the value passed to the dialog is always 0. If there are records in the grid already it works fine.

    So to avoid 0 being passed in I'm trying to get the arg value from the parent grid but the syntax appears to be wrong.

    Any ideas anyone?

  4. #4
    "Certified" Alphaholic
    Real Name
    Andy Gill
    Join Date
    Jul 2011
    Location
    Barbados
    Posts
    1,028

    Default Re: Trouble getting reference to parent grid field

    try this...
    ParentGrid.getValue('G','ADMISSIONID', ParentGrid._selectedRow);

  5. #5
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Re: Trouble getting reference to parent grid field

    Thanks Andy, I've now got this working as follows but have noticed it doesn't work if the grid is open more than once in a TabbedUI.

    I started a new thread for this problem.

    http://msgboard.alphasoftware.com/al...ead.php?101583


    function myfunc() {
    //Get a pointer to the parent component object that opened this Grid and execute a .refresh() method on the parent.
    var po = {grid.object}.getParentObject();
    //If this Grid does not have a parent then 'po' will be false.
    if(po)
    {

    var myID = po.getValue('G','ADMISSIONID',po._selectedRow);
    }
    return myID;

    }

  6. #6
    "Certified" Alphaholic
    Real Name
    Andy Gill
    Join Date
    Jul 2011
    Location
    Barbados
    Posts
    1,028

    Default Re: Trouble getting reference to parent grid field

    As Mauricio suggested, you should try using a predefined open dialog action to ensure you are not overcomplicating things.

  7. #7
    Member
    Real Name
    Richard
    Join Date
    Mar 2012
    Posts
    350

    Default Re: Trouble getting reference to parent grid field

    Thanks Andy, perhaps I am missing something but when I use a predefined dialog action I can't see any way to populate a field using linked options.

    In my case I'm using the "Open a dialog component to edit current record in grid or add a new record" action to Add a new record.

    Try this to replicate what I mean.

    Create a Customer parent grid with a primary key of CustomerID.
    Create an Orders child grid and link it to the parent grid. The foreign key in the Order table might be CustomerID too so the link would be CustomerID = CustomerID.
    The relationship between the grids would be parent one - child many.
    Add an action button to the child grid toolbar calling the "Open a dialog component to edit current record in grid or add a new record" action. Set the Mode to EnterNewRecord.
    You would normally have a field in your dialog that is the foreign key - CustomerID in this case so that the new child rec will be related to the parent record.
    Therefore when you click the action button to add a new record you need to populate the Dialog CustomerID field with the CustomerID from the grid yet there doesn't appear to be any way to "link" this value. If there is please advise.

    So in my case I tried passing the value in using an Argument. Problem is it works if there are records in the Child grid already, but if the Child grid has 0 records the argument value is not passed in correctly... try it and you should see what I mean... it's null if you use an arg of char type or 0 if you use an arg type of numeric.
    So that's why I'm trying to get the value from the parent grid, altough I'm suprised it needed to be this hard. Again, if I'm missing something feel free to point it out as I'm going a little bonkers over this!
    Last edited by rjackson@arach.net.au; 07-25-2012 at 10:26 AM.

  8. #8
    "Certified" Alphaholic
    Real Name
    Andy Gill
    Join Date
    Jul 2011
    Location
    Barbados
    Posts
    1,028

    Default Re: Trouble getting reference to parent grid field

    ok. sounds like you should be setting a global js var. Then you need to add some logic to your dialog that will populate the dialog from the js var if the argument value is 0. There are videos if you need which will help guide you.

Similar Threads

  1. Setting Initial Value in Child Grid new record to value in parent Grid field
    By binque in forum Application Server Version 11 - Web/Browser Applications
    Replies: 12
    Last Post: 08-31-2012, 08:04 PM
  2. Showing data from parent grid field in linked child grid
    By WindForce in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 11-09-2011, 08:43 AM
  3. Show button in Parent Grid based on value in field on Child Grid
    By Cammy in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 11-03-2011, 12:17 PM
  4. actionscript grid.object parent and child reference
    By mpatrizio in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 07-10-2011, 12:58 PM
  5. Init cond question parent field reference
    By Tony Saladino in forum Alpha Five Version 6
    Replies: 9
    Last Post: 08-04-2005, 05:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •