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

Advice on how to show button in grid if a record exists in another table.

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

    Advice on how to show button in grid if a record exists in another table.

    I've been thinking about this for a while and messed around with a couple different ideas that worked but that I didn't like. I'm hoping some of you may have a suggestion or two on the best way to to this.

    What I have is a grid that displays information about our drawings; including a button to download the drawing. This grid is based on my "drawing" table.
    I have another table that's not included in the query for the grid that has a 1 to many relationship with the drawing table. This is my "product to drawing" table.
    The product to drawing table is used in other parts of my application to link a product to a particular drawing.
    I don't want to include my "product to drawing" table on my grid as it would result in duplicate records due to join conditions.
    I have a button (on each row) that opens up another grid based on my "product to drawing" table and linked to the drawing number.

    What I WANT is for the button to change it's style or image so that the user knows when a drawing is not matched to a record in the "product to drawing" table without having to click on the button. Then they can click that button and correct the problem.

    Is there an easy way to do this that I'm missing?


    It would be easy to do this backwards from the "product to drawing" table but most users spend their time in the drawing area and I think I have a better chance of them correcting the records from there.

    Any suggests would be helpful.

    Thanks!

    Jinx

    #2
    Re: Advice on how to show button in grid if a record exists in another table.

    Without seeing your tables it's tough to see if a join could be accomplished that would result in something you could use. Apart from the query, and thinking about the theory of this what, you need to do is reach out to the product to drawing table with it's key from each row in your grid. You could do this with the Client-Side onGridRender. Run a Callback that grabs data and sets a dummy field in your grid rows. Your button could use that field to set it's image etc. Rather do it in the query, though.

    Comment


      #3
      Re: Advice on how to show button in grid if a record exists in another table.

      Hi David,

      Thanks for your reply.

      At this exact moment I'm messing with an SQL command in my OnExistingRowRender server-side-event. I've got it to the point where it can tell me if the record exists in the other table (with a javascript alert just for testing purposes) but I've got to have it emit the right code to change my buttons background or image or something still

      The speed of the different ideas is going to be the most important. I'll have to see how fast it goes with your idea (which is easier to implement since you're client side already) and with mine.

      Comment


        #4
        Re: Advice on how to show button in grid if a record exists in another table.

        I looked at OnExistingRowRender as well... but you'll be issuing a Callback for each row. I wouldn't want that happening. If it can't be helped, then ok. But... that's a lot of work.

        Comment


          #5
          Re: Advice on how to show button in grid if a record exists in another table.

          Yeah, I see what you are saying, after testing a bit. But wouldn't you be doing a callback for each row with your method anyway?

          Also, I'm having a hard time with what javascript to emit to change the style of a button. I know how to disable it:
          $('{Grid.ComponentName}.V.R{Grid.RowNumber}._UNBOUND_BUTTON_7').disabled=true;
          Just haven't figured out how to change it to make it look different or have a different image.

          Comment


            #6
            Re: Advice on how to show button in grid if a record exists in another table.

            No... in theory, onGridRender would issue an Ajax Callback... just once. In that callback you've got access to all your grid data. You have access to your filter (if there is one). You execute one select statement and get back results that will set a field in each row on your grid. The button property disable expression should take care of the rest. You don't need to touch the DOM.

            Comment


              #7
              Re: Advice on how to show button in grid if a record exists in another table.

              Ah, IC.

              Actually, I don't want to disable it. I want to change it's style or image so that a user knows to press it so they can enter data in the other table.

              Comment


                #8
                Re: Advice on how to show button in grid if a record exists in another table.

                Originally posted by -Jinx- View Post
                What I have is a grid that displays information about our drawings; including a button to download the drawing. This grid is based on my "drawing" table.
                I have another table that's not included in the query for the grid that has a 1 to many relationship with the drawing table. This is my "product to drawing" table.
                The product to drawing table is used in other parts of my application to link a product to a particular drawing.

                I don't want to include my "product to drawing" table on my grid as it would result in duplicate records due to join conditions.

                I have a button (on each row) that opens up another grid based on my "product to drawing" table and linked to the drawing number.
                Jinx
                You can do this in SQL and it will be the most efficient from a performance standpoint. Your SELECT statement can return only the fields that you need for your grid so you shouldn't have duplicate values.

                Comment


                  #9
                  Re: Advice on how to show button in grid if a record exists in another table.

                  ^
                  If you join, you'll get duplicate primary keys in your "left" table (on a left join) when your "right" table has more than one record matched to your key field; which in my case, is drawing number and not a unique_id. The "product to drawing" table is a cross-reference table. Those types of tables usually have a many to many relationship where mine has a one to many (in regards to calling it from my drawing table). If I was calling my drawing table from my "product to drawing" table, I'd have a many to one relationship which WOULD work to join from SQL. So, my product to drawing table has a unique product name but the same drawing could be used for multiple products. My drawing table has a unique drawing name but that drawing could be used on multiple products.

                  I need to show all the records in the left table (drawing table).

                  Comment


                    #10
                    Re: Advice on how to show button in grid if a record exists in another table.

                    You don't say what flavor of SQL you're using, so this is prefaced by a bunch of IFs...
                    • IF you are using MSSQL and
                    • IF you can base your grid on a VIEW instead of a table
                    you should be able to do what you are wanting to do

                    Instead of just doing a straight left join
                    Code:
                    SELECT DRAW.Drawing_ID,
                    ...
                    FROM Drawing AS DRAW
                    LEFT JOIN Product_to_Drawing AS PROD
                    ON DRAW.Drawing_ID = PROD.Drawing_ID
                    you instead create a view that performs a left join to a subquery that pulls only the first match from the Product table. Choose only one result by using ROW_NUMBER()
                    Code:
                    SELECT DRAW.Drawing_ID,
                    PROD.Drawing_ID as Prod_Drawing_ID,
                    ...
                    FROM Drawing AS DRAW
                    LEFT JOIN (
                        Select ROW_NUMBER() OVER (PARTITION BY Drawing_ID ORDER BY Drawing_ID) AS DrawingOrder,
                        Drawing_ID,
                        ..
                        FROM Product_to_Drawing
                    ) AS PROD
                    ON DRAW.Drawing_ID = PROD.Drawing_ID
                    AND PROD.DrawingOrder = 1
                    Then, you set your button visibility based on if the field Prod_Drawing_ID is null

                    Comment


                      #11
                      Re: Advice on how to show button in grid if a record exists in another table.

                      Originally posted by -Jinx- View Post
                      Ah, IC.

                      Actually, I don't want to disable it. I want to change it's style or image so that a user knows to press it so they can enter data in the other table.
                      I only mentioned disable 'cause you did. Once you have some data in your grid from the callback you can do anything you like based on it.

                      Still... rather figure out a SQL statement for your grid... but if not possible then this might be a good solution.

                      Comment


                        #12
                        Re: Advice on how to show button in grid if a record exists in another table.

                        Yes, I'm using MSSQL. Jeff, I don't think I could use an "update" on a view, correct? Assuming that's so (which I was), the view (at least the view on the drawing table) wouldn't work. If I did a view on the cross reference table and joined it into the drawing table, it might work though. Thanks for making me think about it outside the box. That still may be an option.

                        David,

                        My problem is not being able to figure out the Javascript to set the image or whatever. The xbasic I can usually get. In any case, if I CAN get it to work with SQL I can just use a conditional style based on a hidden field.

                        Comment


                          #13
                          Re: Advice on how to show button in grid if a record exists in another table.

                          OK,

                          Got it to work with a view so it's at least acceptable for now. I still have some work to do because I can only really link one field this way (the drawing number itself) and can't link it's revision number and status. This will get most of them though.

                          Thanks for your help guys!

                          Comment


                            #14
                            Re: Advice on how to show button in grid if a record exists in another table.

                            A.H
                            Sorry to jump in after a dozen or so posts.
                            This may sound crazy, but let me explain you can always disregard.
                            To the table the grid is based add one more field and populate it with a query to yes or no to start with based on the drawing being present in the other table.
                            Then build the grid and include that field (since you do not want the other tabled joined)
                            So depending on the content yes or no change the caption of the button. And on click of the button download the drawing and set the added field to yes.
                            This will eliminate all the JavaScript to load on the grid or row.
                            The button can be changed easily based on the row cell contents.
                            If sounds crazy please disregard.
                            you don't have to show that field.

                            edit: looks like you solved it.
                            thanks for reading

                            gandhi

                            version 11 3381 - 4096
                            mysql backend
                            http://www.alphawebprogramming.blogspot.com
                            [email protected]
                            Skype:[email protected]
                            1 914 924 5171

                            Comment


                              #15
                              Re: Advice on how to show button in grid if a record exists in another table.

                              Originally posted by jtalbott View Post
                              You can do this in SQL and it will be the most efficient from a performance standpoint. Your SELECT statement can return only the fields that you need for your grid so you shouldn't have duplicate values.
                              Yes, in native SQL you could get a count of the number of child records or you could return the ID of the first child record and if no child exists the returned ID would be null.

                              I think the problem, though, is how to get a subquery into the SQL Statement for the Grid. The SQL builder for the Grid does not fully understand subqueryies (to my knowledge). If you by-pass the point-n-click builder stuff and type it directly into the SQL window in native syntax then you can get an appropriate query which runs in "preview records". When you exit the builder and go back in then Alpha will recognize that the SQL is in native format and display a different builder window. But when you try to set the primary key or save the component you will run into errors.

                              Here are two example queries that should work as native MS-SQL, but they don't. The example quries return 3 columns: 1)Parent key field, 2) parent code value, 3) Number of child records (first query) or the value of the first child record sql finds (second query).

                              SELECT p.SysID, p.CD, (SELECT count (*) FROM Child c where c.pSysID = p.SysID) as Child_Cnt
                              FROM Parent p

                              SELECT p.SysID, p.CD, (SELECT top(1) c.cSysID FROM Child c where c.pSysID = p.SysID) as FirstChild_ID
                              FROM Parent p

                              Comment

                              Working...
                              X