Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to add a linked child grid to the Detail View of a grid?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to add a linked child grid to the Detail View of a grid?

    Hi folks
    I have a grid setup with a detail view set as "popup window". In the popup detail view, i would like to enter a child grid, how can i accomplish that?

    Thanks in advance
    Jaime

    #2
    Re: How to add a linked child grid to the Detail View of a grid?

    There's a video out there somewhere on how to do this, but I can't find it.
    So you'll need to do a few things. First add a 'Static Text' to the DV. Edit the text to be
    Code:
    <div id="child-grid"></div>
    Then add a button below or above it. The button's onClick event needs to Open a grid component. Here's the important part, in the Target setting change it to DIV and change Target DIV ID to child-grid. (I also turn off 'Can hide target DIV?'). Stop here and test your child grid. It should open when you click the button inline where the static text was put. Now that that is working, go to the 'onDetailViewRender' Client-side event and put this code
    Code:
    ele = $('{grid.componentName}.D.V.R1._UNBOUND_BUTTON_1');
    if(typeof ele != "undefined") ele.click();
    That will open the child grid up automatically when you open the DV. (Change the button number accordingly for more than one child-grid.

    EDIT: Hot tip here! I also put the following code on my button after the grid open to totally remove the button after it's been clicked. (requires jQuery)
    Code:
    jQuery(this).parent().parent().remove();

    Comment


      #3
      Re: How to add a linked child grid to the Detail View of a grid?

      Dear Sparticuz
      This not only works as advertised, it also teaches me a few tricks!
      A million thanks!!!

      Jaime

      Comment


        #4
        Re: How to add a linked child grid to the Detail View of a grid?

        Just a small problem now, how can i align the grid completely to the left ( exactly as the labels? ) I see the leftmost part of the grid has an indent to the right...
        See attached picture
        LinkedGridPos.JPG

        Thanks
        Jaime

        Comment


          #5
          Re: How to add a linked child grid to the Detail View of a grid?

          I haven't tried, but you could probably put 'display:none' in the Heading in-line style for the Static Text field.

          Comment


            #6
            Re: How to add a linked child grid to the Detail View of a grid?

            Yup, that did the trick! It messed up the position of the 2 fields that came before, but i fixed it by wrapping those fields in a frame...
            Many thanks for your help
            Jaime

            Comment


              #7
              Re: How to add a linked child grid to the Detail View of a grid?

              Originally posted by Sparticuz View Post

              EDIT: Hot tip here! I also put the following code on my button after the grid open to totally remove the button after it's been clicked. (requires jQuery)
              Code:
              jQuery(this).parent().parent().remove();
              This works great... another way to hide the button is to use '1=2' in the hide/show property of the button.

              Comment


                #8
                Re: How to add a linked child grid to the Detail View of a grid?

                That's a more 'Alpha-friendly' way, but I prefer the jQuery method because it removes the whole row and doesn't have any spacing issues.

                Comment


                  #9
                  Re: How to add a linked child grid to the Detail View of a grid?

                  That makes sense.

                  BTW there is one oddity with this technique that I ran into when I tried it yesterday... First some context: it is A5 v10 SQL/Server web app, the linked-to grid is linked via an SQL identity key. The technique works fine in update mode. But if you tell Alpha to not close down after a new record is inserted, then instead of the linked-to grid showing no records like it should after an insert of the parent grid, it appears with a list of records, presumably based on the linking key of the last record in the grid before the Add button was clicked. Alpha is obviously getting confused.

                  I wonder if somehow using a GUID instead of an identity key might help this situation?

                  Comment


                    #10
                    Re: How to add a linked child grid to the Detail View of a grid?

                    If I understand you correctly, I have that problem as well, I just haven't tackled it yet. So basically what is happening when you are inserting a new parent record there is NO primary key for it yet. (Obviously, because there is no record yet). This presents a problem when the child grid rows contain the parent primary key (which doesn't exist). Using a guid would fix this problem and I'll explain that after the Auto-increment solution.

                    I've been thinking about this for a while. Here is my proposed solution. (I haven't tested or implemented this in my own code yet)
                    • Server-side Event's OnInitialValueCalculate:
                      This event fires before the New Record rows are displayed. It allows you to compute initial values for fields in the Grid.
                      We basically want to get the SQL server's NEXT primary key using something like this
                      Code:
                      show table status like '{table_name}';
                    • This will return a column called 'Auto_increment' which will be the value of the NEXT auto_increment pk.
                    • Then we run
                      Code:
                      e.newValues.id = auto_increment_value
                      and we probably also want to set this as a page/session variable.
                    • On the child grid, I'm not sure what happens, hah. I'm thinking that the linked key should detect the value we've already inserted in the id field and adjust accordingly, if so, we're gold with that solution. It should now allow you to insert child records WITHOUT the parent record already existing. If that doesn't work, then you would just need to set it again from the page/session variable.


                    There are some problems with the above 'pseudo-code'. The main problem being we're not 100% sure the next pk identity will be that auto_increment value. We could get the pk next ai value, fill out our record, someone else inserts a record before we're done (stealing our pk), then saving our record would fail because they took our pk. So this approach is pretty much useless in a concurrent environment.

                    Thinking about this, GUID's would be alot easier. The reason being is because of the 'non-existent' chance of pk collision. The steps would basically be the same as the above steps, except instead of querying the sql server for the next primary key, we would create the pk ourselves. By running a xbasic function that creates a new guid. I know it exists, but I can't find the wiki page, hah! Then just use the new guid in the OnInitialValueCalculate. The BIG plus of using a guid is that if someone else inserts in that table while you are still working, they would have gotten a different guid, again, because of the 'non-existent' chance of a collision.

                    Comment


                      #11
                      Re: How to add a linked child grid to the Detail View of a grid?

                      With the GUID approach, you suggest creating it via an xbasic function. Could this also be done with Javascript and the pk initialized in the AfterDetailViewNewRecord client event?

                      Comment


                        #12
                        Re: How to add a linked child grid to the Detail View of a grid?

                        I would assume it could be done there as well. http://stackoverflow.com/questions/1...-in-javascript

                        Comment


                          #13
                          Re: How to add a linked child grid to the Detail View of a grid?

                          Thanks, I saw that and was wondering, as one comment was: "However, note in the comments that such values are not genuine GUIDs. There's no way to generate real GUIDs in Javascript, because they depend on properties of the local computer that browsers do not expose."

                          Yet someone else says, "Actually, the RFC allows for UUIDs that are created from random numbers. You just have to twiddle a couple of bits to identify it as such."

                          But of course, I just realized probably the best way is to simply create it in SQL (as the initial for the column using the NEWID() function):

                          http://www.dailycoding.com/Posts/gen...ql_server.aspx

                          Comment


                            #14
                            Re: How to add a linked child grid to the Detail View of a grid?

                            I'm not terribly familiar with uuid's but from what I know, the rate of collision is so low it's practically impossible. I wouldn't worry about 'genuine' guid's, just follow the rfc standard.

                            Comment


                              #15
                              Re: How to add a linked child grid to the Detail View of a grid?

                              Update:

                              I had a closer look at what was going on and found that your technique does actually work after an Add. What I discovered was that I had some bad data in the child grid's main table. When I cleaned that up it started working as expected. So there is probably no reason to resort to GUID's.

                              BTW, if you do need to use GUIDs*, I found you can do this:

                              -In the CanInsertRecord server event, use the Xbasic function api_uuidcreate() to initialize the GUID key.

                              *To create a table with a GUID, you can do this:

                              -Define the column as varchar(36), and set it to be the primary key.
                              -Set the default to newid(), if you aren't setting it in Xbasic.

                              Comment

                              Working...
                              X