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

Grid Custom Control with sql_lookup

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

    Grid Custom Control with sql_lookup

    I'm having an issue which I think is a bug, or maybe im missing a line of code....anyways:

    I have a very common situation: a foreign key in a grid which I want to display a useful value for: Instead of an id, id like to show some other datapoint.

    Im building a timesheet/billing program and I have a rate table which holds employee rates. This table has a rateID as a primary key.

    I also have a payment table which has a payment record and has a field called rateID which references the record in the rate table.
    It seems that using the sql lookup, every row is using the same value..selwyns commenting says 'data parameter contains the value for each row'

    I have 2 records, one has rateID: 1, the other has rateID: 7

    Here is my custom code

    Dim code as C
    code=data.ratID

    Dim rate as c
    rate=sql_lookup("::name::mysql_billing", "rate", "ratID="+code,"ratRate");

    'Write Xbasic code here that returns the HTML to be displayed by this control
    ratID_render = <<%html%
    <label>Code was: <%a5 ?code %></label>
    <label><%a5 ?rate %></label>
    %html%

    When i look at the grid both records say Code was: 7.
    I KNOW this is incorrect, why isn't it using the correct value for the row?

    Any help or advice would be appreciated
    Scott Moniz - Computer Programmer/Analyst
    REA Inc.
    http://reainc.net
    (416)-533-3777
    [email protected]

    REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
    If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
    contact us to discuss options.

    #2
    Re: Grid Custom Control with sql_lookup

    did you ever get this working? i would like to know how to do this as well

    Comment


      #3
      Re: Grid Custom Control with sql_lookup

      Hi Sparticuz,

      We never got a response or workaround for this, and we haven't got back to working on this.

      If you figure out a solution, we'd appreciate it if you could let us know what you did.

      Thanks,

      Robert
      Earl Allin
      REAInc.net

      We can help you with mentoring and custom programming services in Alpha, .NET, React, PHP, ColdFusion, and more..

      Comment


        #4
        Re: Grid Custom Control with sql_lookup

        sql_lookup works fine for me
        heve you tried
        Code:
        rate=sql_lookup("::name::mysql_billing", "rate", "ratID="+[COLOR="Red"]quote[/COLOR](code),"ratRate")
        (No need for that closing ';' on xbasic code)
        Cheers
        Mauricio

        Comment


          #5
          Re: Grid Custom Control with sql_lookup

          Hi

          If I am not totally mistaken, the problem is that you try to output the value of the field using <%a5> tags.

          While a custom control HTML is evaluated in each row, <%a5 ...%> tags are not, i.e. they are evaluated by the server once when the page is (re-)loaded. So, I assume what happens is, that it will evaluate all code values but take only the last one to send to the server evaluating the <%a5 tags.

          You have to insert the value of the variable in the the custom control's HTML in a different way, for example

          Code:
          dim code as ...
          code=...
          dim rate as ...
          rate=...
          ratID_render = <<%html%
          <label>Code was: [B][COLOR="Blue"]{code}[/COLOR][/B]</label>
          <label>[COLOR="blue"][B]{rate}[/B][/COLOR]</label>
          %html%
          ratID_render = [B][COLOR="blue"]evaluate_string(ratID_render)[/COLOR][/B]
          See evaluate_string() in the online help.

          You can also easily verify this with the following examples:

          This is using the <%a5> tag and it will fail to print ALL row numbers. Instead, only the last row number is shown for each custom control:

          Code:
          dim code as N
          
          code=args.RowNumber
          ratID_render = <<%html%
          <%a5 ?code %></label>
          %html%
          This example uses evaluate_string() and evaluates the correct row number for each row:

          Code:
          dim code as N
          
          code=args.RowNumber
          ratID_render = <<%html%
          {code}
          %html%
          ratID_render=evaluate_string(ratID_render)
          cheers

          Wolfgang
          Last edited by wmz; 04-20-2010, 06:04 PM. Reason: typo

          Comment


            #6
            Re: Grid Custom Control with sql_lookup

            For some reason I'm getting an error.

            This works in the interactive window:
            Code:
            ?sql_lookup("::name::jkapp","Telemarketing.TelemarketingProspects", "ProspectID=1", "ProspectName")
            This produces an error message:
            Code:
            dim prospect as c
            prospect = sql_lookup("::name::jkapp","Telemarketing.TelemarketingProspects", "ProspectID="Data.Prospect_fk, "ProspectName")
            Prospect_fk_render = <<%html%
            <label>{prospect}</label>
            %html%
            Prospect_fk_render = evaluate_string(Prospect_fk_render)
            
            ERROR:
            Error in custom control xbasic: Variable type mismatch: attempt to pass data of type 'N' to argument 'filter ' is of type 'C'.
            I've also tried convert_type(Data.Prospect_fk, "C")

            Comment


              #7
              Re: Grid Custom Control with sql_lookup

              Try:

              Code:
              prospect = sql_lookup("::name::jkapp","Telemarketing.TelemarketingProspects", "ProspectID=" [COLOR="Red"]+quote([/COLOR]Data.Prospect_fk[COLOR="Red"])[/COLOR], "ProspectName")
              Jim Coltz
              Alpha Custom Database Solutions, LLC
              A5CustomSolutions.com
              [email protected]

              Comment


                #8
                Re: Grid Custom Control with sql_lookup

                Code:
                Error in custom control xbasic: quote(Data.Prospect_fk): Argument is incorrect data type
                btw, Prospect_fk is an int

                Comment


                  #9
                  Re: Grid Custom Control with sql_lookup

                  Originally posted by Sparticuz View Post

                  btw, Prospect_fk is an int
                  OK then, we need to use s_quote() for and integer. From the interactive window:

                  Code:
                  dim n as n
                  
                  n =1
                  
                  ?"ProspectID=" +quote(n)
                  ERROR: Argument is incorrect data type
                  
                  ?"ProspectID=" +s_quote(n)
                  = "ProspectID=1"
                  Jim Coltz
                  Alpha Custom Database Solutions, LLC
                  A5CustomSolutions.com
                  [email protected]

                  Comment


                    #10
                    Re: Grid Custom Control with sql_lookup

                    Originally posted by Jim Coltz View Post
                    OK then, we need to use s_quote() for and integer.
                    That did it! Awesome.

                    Comment


                      #11
                      Re: Grid Custom Control with sql_lookup

                      Thank you all for the above notes - i am able to get this working on a grid.

                      However, I'm now trying to use Custom fields on the Form only grid.

                      I've got the following code for the custom field (this does work for the Grid):

                      PHP Code:
                      Dim strGiven as C
                      Dim strSurname 
                      as C
                      Dim intPerID 
                      as N

                      intPerID 
                      Data.perID

                      strGiven 
                      sql_lookup("::name::mysql_billing","person","perID="+s_quote(intPerID),"perGiven")
                      strSurname sql_lookup("::name::mysql_billing","person","perID="+s_quote(intPerID),"perSurname")

                      Dim strPersonName as C
                      strPersonName 
                      trim(strGiven " " strSurname)

                      perID_render = <<%html%
                      <
                      label>{strPersonName}{intPerID}</label>
                      %
                      html%
                      perID_render evaluate_string(perID_render
                      As i click on the NEXT icon for the next record in the form view, I'm getting the same value for the name and ID.

                      The other textbox fields are correctly changing to show the values from the database.

                      Is there anyway to get the form to read the correct perID when moving through the records using the form only grid?

                      Thanks,

                      Robert

                      Anyone have any suggestions?
                      Earl Allin
                      REAInc.net

                      We can help you with mentoring and custom programming services in Alpha, .NET, React, PHP, ColdFusion, and more..

                      Comment


                        #12
                        Re: Grid Custom Control with sql_lookup

                        Maybe you need to refresh the row after the record changes like {grid.object}.RefreshRow(1) in the Javascript system events OnRowRender?
                        Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                        Comment


                          #13
                          Re: Grid Custom Control with sql_lookup

                          I'm needing something very similar--when I make a change in the Detail View and submit it, the Grid row reflects the change but the Custom Control doesn't get refreshed. Did you ever figure this out and/or does anyone know how to call the custom control to refresh itself without having to refresh the entire grid?

                          Thanks...

                          Comment

                          Working...
                          X