Alpha Video Training
Results 1 to 8 of 8

Thread: Send Javascript from embedded grid to parent dialog

  1. #1
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Send Javascript from embedded grid to parent dialog

    I know how to execute methods from a parent dialog to an embedded grid.
    But is it possible to send Javascript back to the parent dialog from an embedded grid ?

    If so, some syntax or a reference to a relevant forum thread would be much appreciated.

    Thanks,
    Joshua

  2. #2
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Send Javascript from embedded grid to parent dialog

    I got this from one of the many videos. I'd tell you which one but I have no idea which one it was. I used it in a server side event

    dim js as c
    js = <<%txt%
    var parentGrid= __gridObject__.getParentObject();
    rowNum = parentGrid._selectedRow;
    parentGrid.setValue('D','STATUS','Unaudited'); 'these 2 lines are my code
    parentGrid.refreshRow(rowNum); 'replace them with whatever you need
    %txt%
    js = stritran(js,"__gridObject__",e.gridDefinition.componentname + "_GridObj")

    aa = e.rtc.A_AjaxResponses
    aa[].text = js
    aa[..].id = 100 'the order in which AjaxResponses are sent to the browser

  3. #3
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Re: Send Javascript from embedded grid to parent dialog

    Thanks, Lee. I'll play around with this in detail and get back to you.
    In a nutshell, I have a parent dialog with 2 embedded grids. Upon a row insert, I need grid1 to send a message back to the dialog telling grid2 to refresh.

  4. #4
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Re: Send Javascript from embedded grid to parent dialog

    Bummer so far. I put the code below in the AfterInsertRecord server event.
    I even added a STATUS field in the parent dialog to replicate your code.
    The first alert worked. However, any Javascript I try to execute with the 'parentGrid' prefix throws a 'Unterminated String Constant' error.

    dim js as c
    js = <<%txt%
    alert('hello world');
    var parentGrid= __gridObject__.getParentObject();
    parentGrid.setValue('D','STATUS','Unaudited');
    %txt%
    js = stritran(js,"__gridObject__",e.gridDefinition.componentname + "_GridObj")

    aa = e.rtc.A_AjaxResponses
    aa[].text = js
    aa[..].id = 100 'the order in which AjaxResponses are sent to the browser

  5. #5
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Re: Send Javascript from embedded grid to parent dialog

    Correction: This is what I'm getting.
    Any chance there is a different syntax for a parent dialog as opposed to a parent grid?

    dfdfdf.PNG

  6. #6
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Re: Send Javascript from embedded grid to parent dialog

    Okay, I decided to simplify this.

    var parent = {grid.Object}.getParentObject();
    alert(parent);

    Returns 'undefined'.

  7. #7
    Member
    Real Name
    Lee Cook
    Join Date
    Mar 2010
    Posts
    217

    Default Re: Send Javascript from embedded grid to parent dialog

    You need to drop the line with status in it. I use that line to set the value of the status field in the parent record to "unaudited". That will certainly cause an error if you try to run it since you don't have a field named Status. You definitely need to drop both lines of my code.

    What are trying to do with the parent record?

  8. #8
    Member
    Real Name
    Joshua R. Turner
    Join Date
    Oct 2011
    Posts
    85

    Default Re: Send Javascript from embedded grid to parent dialog

    I modified my dialog to support your code. That wasn't the issue.
    For whatever reason, my embedded grids have a tough time getting parent dialog pointers.
    So here's what I have done.

    The parent dialog's client-side onRenderComplete event has this:
    var obj = {id: '{dialog.object}', row: '{dialog.RowNumber}' }; // reference to parent dialog
    window['__pd'] = obj;

    And when I want embedded grid1 to tell the parent dialog to refresh embedded grid2, I execute this:
    var parentDialog = window['__pd'];
    if (typeof parentDialog != 'undefined')
    {
    var parentDialogAlias = window['__pd'].id;
    var parentObj = window[parentDialogAlias];
    var row = window['__pd'].row;
    parentObj.setValue('REFRESH_DETAILS','refresh');
    }

    The REFRESH_DETAILS field has an on-change event that executes this:
    {dialog.EmbeddedGrid_DETAILS}.refresh();

    I say, whoop. Whoop.

Similar Threads

  1. Refresh parent grid from dialog - should be simple
    By agillbb in forum Application Server Version 11 - Web/Browser Applications
    Replies: 7
    Last Post: 08-21-2012, 12:55 AM
  2. Populate field in dialog with parent grid value
    By rjackson@arach.net.au in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 07-19-2012, 09:22 AM
  3. Populate dialog field with value from parent grid
    By rjackson@arach.net.au in forum Application Server Version 11 - Web/Browser Applications
    Replies: 5
    Last Post: 06-30-2012, 08:08 AM
  4. Javascript to set mapped parent grid fields from a Lookup component-Unselect Button
    By RichCPT in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 01-10-2012, 11:57 PM
  5. Send email automatically based on field value in GRID or DIALOG
    By den1s in forum Application Server Version 8
    Replies: 7
    Last Post: 09-19-2007, 06:15 PM

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
  •