Alpha Video Training
Results 1 to 9 of 9

Thread: Linked grids - first row on parent will not be selected.

  1. #1
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Linked grids - first row on parent will not be selected.

    Hello.
    I have a parent grid which is used to select a new row on a child grid.
    The keys in the linked grids is shown up on the child grid automatically.

    In order to pass a variable value from the parent grid to the child I have coded:
    window['var1']={grid.Object}.getValue('G','KONKURSBONAVN',{Grid.RowNumber});
    var xvar1='';
    if(window['var1']) xvar1=window['var1']
    else xvar1='value not found';
    $('E1').innerHTML=xvar1;
    {grid.Object}.setValue('G','KONKURSBONAVN',-1,xvar1);


    But this does not work if I press the first button or when the page is initialized the first time.
    If I press the second button it works.
    And again press the first button it works.
    Any suggestion much appreciated.
    Thanks.

    alpha1.jpg

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,862

    Default Re: Linked grids - first row on parent will not be selected.

    This was a little tough until I recalled other problems with timing. The problem here is that the value is being written to the grid and then the grid rows are being fetched. I put a setTimeout function in place to delay the value being written. You can play with the timing to see what works best for you. The last problem with the solution was that the setValue statement has to be parsed out to there are a bunch of escaped single quotes to deal with... but it does work. Hope it's what you're looking for.

    Code:
    window['var1']={grid.Object}.getValue('G','KONKURSBONAVN',{Grid.RowNumber});
    var xvar1='';
    if(window['var1'])
    {
     xvar1=window['var1'];
    }
    else
    {
     xvar1='value not found';
    }
    $('E1').innerHTML=xvar1;
    var t=setTimeout('{grid.Object}.setValue(\'G\',\'KONKURSBONAVN\',-1,\'' + xvar1 + '\');',500);

  3. #3
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Re: Linked grids - first row on parent will not be selected.

    Thanks Davidk for your kind help.
    I tried this, but was unsuccessful in getting it to work.
    Even if I put a delay to be ahead before the whole code it did not work.
    As you can see there needs to be a delay before the xvar1 assignment.
    I have a feeling that this way of doing it might be wrong in spite of Web Application Video number #69.
    The reason is that I can push the first button many times without any luck.

    Alpha five - where is the video which shows the many ways of passing parameters?
    There are so many of us who are new to this and needs it.


    I have been looking at events.
    Parent: OnExistingRowRender e.rv.session.lastname = e.rowData.data("lastname")
    Child: OnGridExecute ????? = e.rv.session.lastname

    Any suggestion welcomed with gladness.
    Thanks.

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,862

    Default Re: Linked grids - first row on parent will not be selected.

    Ok, let's get a bit more detailed because without some basic setup information it's tough to replicate what you're doing.

    You have a grid, and under Properties you are using the Linked Grids/Content section. You've defined a Linked Grid and specified it's location at the Freeform Region, Bottom of your grid. It looks like the "detail" grid you are displaying is a single record, form grid. Is all this correct? If so, then the code should work. The setTimeout is creating a delay of half a second before the setValue is taking place. Change the value of the delay a bit until it's working.

    Video # 69 is completely different from what you're trying to do... in a sense. This video is specifically opening a child grid from a parent grid and so you have lots of other events available. In your case, you're dealing with a linked child grid that is already open and so you're just updating already displayed data.

    I don't think OnGridExecute in the linked child grid will work because it only gets called when the grid is first executed (and on every Ajax callback - which may not apply here). To test this, in the linked child OnGridExecute put e.tmpl.rows=10. Now run your parent grid and you should see 10 rows displayed in the linked child. Now manually change the records per page to 1 in the linked child and then choose another parent record. The linked child grid stays at the records per page you selected - the code doesn't run again, in this case.

    Try the code below... I've modified it a bit to include your assignment to the "E1" div. Again, this must be delayed a bit until the linked child record is done fetching records.

    Code:
    window['var1']={grid.Object}.getValue('G','PRODNAME',{Grid.RowNumber});
    var xvar1='';
    if(window['var1'])
    {
     xvar1=window['var1'];
    }
    else
    {
     xvar1='value not found';
    }
    
    var t=setTimeout('{grid.Object}.setValue(\'G\',\'PRODDETAILS\',-1,\'' + xvar1 + '\'); $(\'E1\').innerHTML=\'' + xvar1 + '\';',500);
    Last edited by Davidk; 06-16-2011 at 09:07 AM.

  5. #5
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Re: Linked grids - first row on parent will not be selected.

    Thanks Davidk, I really appreciate your good response and support.
    I think I must have not explained my case good enough.

    The parent is a tabular read only grid where I have defined 2 link fields.
    On the child you can only see one of them as one of them is hidden.
    The two link fields works perfectly.

    The child is a form updateable grid with ADD RECORDS ONLY (only insert is allowed).
    There is no detail part or search part.
    The user select the row from the parent.
    The first time there is no select from the user and the child grid shows the linked fields from the parent but cannot display the passed parameter.

    I tried your suggestion and after that just to make sure used the following parameters:
    var xvar1='';
    if(window['var1']) xvar1=window['var1']
    else xvar1='value not found';
    var t=setTimeout('{grid.Object}.setValue(\'G\',\'KONKURSBONAVN\',-1,\'' + xvar1 + '\'); $(\'E1\').innerHTML=\'' + xvar1 + '\';',2500);
    if(window['var1']) xvar1=window['var1']
    else xvar1='value not found';
    var t=setTimeout('{grid.Object}.setValue(\'G\',\'KONKURSBONAVN\',-1,\'' + xvar1 + '\'); $(\'E1\').innerHTML=\'' + xvar1 + '\';',2500);


    I could feel the delay but had no luck, sorry about that.
    Probably because you expected me having another type of child grid.
    Thanks for your kind help.

  6. #6
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,862

    Default Re: Linked grids - first row on parent will not be selected.

    I don't think your "If" statement is correct. Personally, I don't like the way it looks - hard for me to read, but that's just me. However, your code fails in my grid, until I put a semi-colon at the end of your first if statement.
    I think you need...

    if(window['var1']) xvar1=window['var1'];
    else xvar1='value not found';

    But I like mine a bit better 'cause it's easier for me to read.

  7. #7
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Re: Linked grids - first row on parent will not be selected.

    OK Davidk, I have never taken the time to learn javascript.
    It is time to start learning it.
    However that does not change anything, as you can see from my first post.
    Thanks anyway.

  8. #8
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Re: Linked grids - first row on parent will not be selected.

    Bump.

  9. #9
    Member
    Real Name
    Jon Mangschou
    Join Date
    May 2011
    Posts
    41

    Default Re: Linked grids - first row on parent will not be selected.

    OK, thanks to Davidk the solution.
    Davidk the Genius, was not aware that he had solved this problem already in february 2011.
    Also I have learned that I must be much clearer in describing my problem if I want to get help.

    After reading many posts on this forum, I realize that many questions on this forum remain unanswered.
    Only to get an answer is a blessing indeed. So it is good that we beginners can try to answer our own problems if we get one. Not everyone is so lucky to get the problem solved by others as I have.

    The learning videos, samples and documentation seem to avoid these crucial subjects:
    -The many ways of passing parameters.
    -Events, when and how to use them.
    -Xbasic for web

    The Solution:
    The parent is a tabular read only grid where I have defined link fields.
    The child is a single form updateable grid with ADD RECORDS ONLY (only insert is allowed).
    There is no detail part or search part.
    The user selects the row from the parent and an extra field is needed to be copied from the parent to child.
    The parent grid will work with or without a button, but it is always nice for the user to have a button instead of only a small arrow.

    Javascript child only (no need of parent coding) – System events – OnGridRender
    var fieldname = "";
    var po_rowNum = "";
    var po = {grid.Object}.getParentObject();
    if (po) po_rowNum = po._selectedRow;
    if (po) fieldname = po.getValue('G','FIELDNAME', po_rowNum);
    {grid.Object}.setValue('G','FIELDNAME',-1,fieldname);


    Important links:
    If your child grid is different from a single insert row, then see the links below.
    Maybe you have multiple child rows with read, update etc.

    http://news.alphasoftware.com/v10preview/videos.htm
    #69 Did not solve my problem but see it.

    http://msgboard.alphasoftware.com/al...-child-windows
    Videos shown by Bob Moore – very valuable

    http://msgboard.alphasoftware.com/al...-causing-error
    Davidk with the correct solution.

    Thanks to Davidk for his kind help.

Similar Threads

  1. duplicate linked grids with in the linked grid
    By gwitasod in forum Application Server Version 10 - Web/Browser Applications
    Replies: 3
    Last Post: 04-18-2011, 10:11 AM
  2. Issue: "Row Expander" vs "Linked Grids/Content"
    By roberto in forum Application Server Version 10 - Web/Browser Applications
    Replies: 8
    Last Post: 02-08-2011, 06:36 PM
  3. Grid - Properties - Row Expander - Row Expander Linked Grids
    By rnoguera in forum Archived Wishlist
    Replies: 1
    Last Post: 11-22-2010, 01:49 PM
  4. Linked Grids Content versus Row Expander problem
    By kingcarol in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 08-04-2010, 05:30 PM
  5. Result.ErrorHTML problem with Row Expander Linked Grids
    By fsi in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 10-26-2009, 02: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
  •