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

Using Ajax in the Desktop Product

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

    Using Ajax in the Desktop Product

    Hi,

    I was watching the video on using Ajax in Alpha Five. It was this particular video on cascading menus.

    I am aware that using AJAX to filter the data can be done in the Web program code of Alpha Five v9 but what about the desktop version? That particular code/function is what I was looking for, but is that only limited to the web part of Alpha Five V9?

    #2
    Re: Using Ajax in the Desktop Product

    Here's one way to do it, also using the Alpha Sports database:
    Code:
    ' choose customer
    states=table.external_record_content_get("customer","Bill_State_Region","Bill_State_Region",\
    "unique_key_value()")
    cities=" "
    customers=" "
    
    reslt=ui_dlg_box("Choose customer",<<%dlg%
    State: |[.10,5state^#states!chooseState];
    City: |[.20,5city^#cities!chooseCity];
    Customer: |[.30,5customer^#customers];
    <OK> <Cancel>;
    %dlg%,<<%code%
    if a_dlg_button="chooseState" then
        a_dlg_button=""
        cities=table.external_record_content_get("customer","Bill_City","Bill_City",\
        "bill_state_region="+quote(state)+" .and. unique_key_value()")
        customers=" "
    end if
    if a_dlg_button="chooseCity" then
        a_dlg_button=""
        customers=table.external_record_content_get("customer","Lastname-','+Firstname","Lastname-','+Firstname",\
        "bill_state_region="+quote(state)+" .and. bill_city="+quote(city))
    end if
    %code%)
    
    if reslt="OK" then
        ui_msg_box("You chose",customer+crlf()+"from "+city-", "+state)
    end if

    Comment


      #3
      Re: Using Ajax in the Desktop Product

      And here's another, which I think is more elegant:
      Code:
      tree=table.external_record_content_get("customer","trim(Bill_State_Region)","Bill_State_Region",\
      "unique_key_value()")
      
      reslt=ui_dlg_box("Choose customer",<<%dlg%
      [%S=BLR;D="\"%.40,15node^<tree!navigate];
      
      <OK?(occurs(chr(92),node)=2)> <Cancel>;
      %dlg%,<<%code%
      if a_dlg_button="navigate" then
          a_dlg_button=""
          nodeLevel=occurs(chr(92),node)
          select
          	case nodeLevel=0 
              ' we just chose a state
              cities=table.external_record_content_get("customer","trim(bill_city)","bill_city",\
              "bill_state_region="+quote(node)+" .and. unique_key_value()")
              cities=*for_each(tag,node+chr(92)+tag,cities)
              tree=stritran(tree,node,trim(cities))
            case nodeLevel=1
              ' we have a state and a city
              state=word(node,1,"\\")
              city=word(node,2,"\\")
              customers=table.external_record_content_get("customer","Lastname-', '+Firstname",\
              "Lastname-', '+Firstname","bill_state_region="+quote(state)+" .and. bill_city="+quote(city))
              customers=*for_each(tag,node+chr(92)+tag,customers)
              tree=stritran(tree,node,trim(customers))
          end select
      end if
      
      %code%)
      
      if reslt="OK" then
      	customer=word(node,3,"\\")
          ui_msg_box("You chose",customer+crlf()+"from "+city-", "+state)
      end if

      Comment


        #4
        Re: Using Ajax in the Desktop Product

        Originally posted by Tanman View Post
        Hi,

        I was watching the video on using Ajax in Alpha Five. It was this particular video on cascading menus.

        I am aware that using AJAX to filter the data can be done in the Web program code of Alpha Five v9 but what about the desktop version? That particular code/function is what I was looking for, but is that only limited to the web part of Alpha Five V9?
        you don't need to use ajax in the desktop because on the desktop, there is no need to communicate asynchronously with a server (as is the case in a web application). creating cascading dropdown boxes on the desktop is therefore much easier.


        this example is in the sample 'Learning Xdialog' database that ships with Alpha Five. It is in the 'whats new in v8' section - 'Tree control' - 'Select a customer - Populate dynamically from a table' example.

        (you can open alphasports, and test it out)

        Code:
        
        dim filterExpn as c
        dim orderExpn as c 
        dim contentExpn as c 
        dim tablename as c 
        
        tablename = "customer"
        contentExpn = "alltrim(bill_state_region)+'|{EXPAND=Expanding tree...}!expandState('+quote(alltrim(bill_state_region))+')'"
        filterExpn = "bill_state_region<> '' .and.unique_key_value()"
        orderExpn = "bill_state_region"
        
        dim treeList as c 
        treeList = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
        dim selected as c = ""
        
        'The enable expression for the OK button looks to see if the 'selected' variable starts with 'ID:'
        'If so, then we know we are at an endpoint in the tree.
        
        dim flagOK as l = .f.
        
        ui_dlg_box("Select Customer",<<%dlg%
        [%X;S=BLR;D="|"%.50,20selected^<treelist];
        
        {justify=right}
        <10&OK!ok?left(selected,3)="ID:"> <Cancel>;
        %dlg%,<<%code%
        if a_dlg_button ="ok" then 
        	flagOK = .t.
        end if 
        %code%)
        
        
        if flagOK = .t. then 
        	ui_msg_box("","You selected customer number: " + substr(selected,4))
        	
        end if 
        
        
        function expandState as c (state as c )
        ui_yield()
        dim filterExpn as c
        dim orderExpn as c 
        dim contentExpn as c 
        dim tablename as c 
        tablename = "customer"
        contentExpn = "alltrim(bill_city)+'|{EXPAND=Expanding tree...}!expandCity('+quote(alltrim(bill_city))+')'"
        filterExpn = "unique_key_value() .and. bill_state_region=" + quote(state)
        orderExpn = "bill_city"
        
        expandState = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
        
        if expandState = "" then 
        	expandState = "<None>"
        end if 
        	
        end function
        
        
        
        function expandCity as c (city as c )
        ui_yield()
        	
        dim filterExpn as c
        dim orderExpn as c 
        dim contentExpn as c 
        dim tablename as c 
        tablename = "customer"
        contentExpn = "'{DATA=ID:'+customer_id+'}'+alltrim(lastname)+', ' + alltrim(firstname)"
        filterExpn = "unique_key_value() .and. bill_city=" + quote(city)
        orderExpn = "lastname"
        
        expandCity = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
        
        if expandCity = "" then 
        	expandCity = "<None>"
        end if 
        	
        end function

        Comment


          #5
          Re: Using Ajax in the Desktop Product

          Hi,
          Now that Wei-Yen's question (I believe) has been answered, I have a related one. Two somewhat different approaches and I cannot see right away why Peter Wayne's tree does not open with it ready to expand with a plus sign along each node until the node is placed in focus??....or vice-versa, why does the sample Selwyn gave start out the way it should with the tree ready to expand?

          I figured to ask as it most likely is something that both Peter and Selwyn would know right away.

          I think it involves
          |{EXPAND=Expanding tree...}!
          But do not recognise the syntax and do not know if it can be used in any tree....

          Later--or one difference is the option of %X....the populating with crlf...
          Last edited by MikeC; 05-31-2008, 11:59 AM.
          Mike
          __________________________________________
          It is only when we forget all our learning that we begin to know.
          It's not what you look at that matters, it's what you see.
          Henry David Thoreau
          __________________________________________



          Comment


            #6
            Re: Using Ajax in the Desktop Product

            Originally posted by MikeC View Post
            Hi,
            Now that Wei-Yen's question (I believe) has been answered, I have a related one. Two somewhat different approaches and I cannot see right away why Peter Wayne's tree does not open with it ready to expand with a plus sign along each node until the node is placed in focus??....or vice-versa, why does the sample Selwyn gave start out the way it should with the tree ready to expand?

            I figured to ask as it most likely is something that both Peter and Selwyn would know right away.

            I think it involves
            |{EXPAND=Expanding tree...}!
            But do not recognise the syntax and do not know if it can be used in any tree....

            Later--or one difference is the option of %X....the populating with crlf...


            the example that I quoted in my earlier post (from the learning Xdialog samples) is actually an amazingly powerful example (and deceptively simple)


            when the tree is initially populated it looks like this:
            Code:
            AZ|{EXPAND=Expanding tree...}!expandState("AZ")
            CA|{EXPAND=Expanding tree...}!expandState("CA")
            CT|{EXPAND=Expanding tree...}!expandState("CT")
            DC|{EXPAND=Expanding tree...}!expandState("DC")
            and so on....

            as you see, there is very little data in the tree. just a list of states.
            this means that even if you are displaying a tree on a huge multi-level data source, it populates very quickly.

            however, every node in the tree has a function call.
            in the case of the first entry, the function call is

            Code:
            expandState("AZ")
            so, when you click on the + icon to expand 'Arizona', the function is called. In this case the function executes so quickly that you don't notice the message 'Expanding tree'. But if the function took a long time to execute then the tree would say 'Expanding tree' until the function completed.

            If you look at the SQL Database Explorer, you will that as you explore the tables in the Remote database, and then the columns in each table, this technique is used very effectively.

            after the expandState("AZ") function has completed, the data in the tree looks like this:


            Code:
            AZ|Phoenix|{EXPAND=Expanding tree...}!expandCity("Phoenix")
            AZ|Tucson|{EXPAND=Expanding tree...}!expandCity("Tucson")
            CA|{EXPAND=Expanding tree...}!expandState("CA")
            CT|{EXPAND=Expanding tree...}!expandState("CT")
            DC|{EXPAND=Expanding tree...}!expandState("DC")
            and so on....

            this ability to dynamically populate the tree is very powerful (and is analagous to the AJAX tree examples our videos demonstrate for the Web).

            Comment


              #7
              Re: Using Ajax in the Desktop Product

              There's an error in the tree code I posted; if the user navigates back and forth, a node can append to itself. This code fixes that by checking to see if a node has already been expanded:
              Code:
              tree=table.external_record_content_get("customer","trim(Bill_State_Region)","Bill_State_Region",\
              "unique_key_value()")
              
              reslt=ui_dlg_box("Choose customer",<<%dlg%
              [%S=BLR;D="\"%.40,15node^<tree!navigate];
              
              <OK?(occurs(chr(92),node)=2)> <Cancel>;
              %dlg%,<<%code%
              if a_dlg_button="navigate" then
                  a_dlg_button=""
                  children=filter_string(tree,node+chr(92),crlf(),.f.)
                  if children="" then  ' this node has not been expanded yet
              	    nodeLevel=occurs(chr(92),node)
              	    select
              	    	case nodeLevel=0 
              	        ' we just chose a state
              	        cities=table.external_record_content_get("customer","trim(bill_city)","bill_city",\
              	        "bill_state_region="+quote(node)+" .and. unique_key_value()")
              	        cities=*for_each(tag,node+chr(92)+tag,cities)
              	        tree=stritran(tree,node,trim(cities))
              	      case nodeLevel=1
              	        ' we have a state and a city
              	  		
              	        state=word(node,1,"\\")
              	        city=word(node,2,"\\")
              	       ' tree=stritran(tree,state,node)
              	        customers=table.external_record_content_get("customer","Lastname-', '+Firstname",\
              	        "Lastname-', '+Firstname","bill_state_region="+quote(state)+" .and. bill_city="+quote(city))
              	        customers=*for_each(tag,node+chr(92)+tag,customers)
              	        tree=stritran(tree,node,trim(customers))
                  end select
                  end if
              end if
              %code%)
              
              if reslt="OK" then
              	customer=word(node,3,"\\")
                  ui_msg_box("You chose",customer+crlf()+"from "+city-", "+state)
              end if
              In this example, of a simple 3-level structure of state->city->customer, Selwyn's code and mine produce the same result. If, however, you have a tree in which some branches end after 1 node, others 2, others 3, etc., then it's hard to use Selwyn's technique, because it depends on knowing in advance whether a node is a terminal node or not. I could be wrong on that, but I personally could never get the %X..{EXPAND} method to work on a lopsided tree structure with uneven branches.

              Comment


                #8
                Re: Using Ajax in the Desktop Product

                Thanks for replying back. What you describe is exactly what I am trying to do but for a combo box. I have my database included in here, and I have figured that I might have to use the edit filter expression.

                I have my database attached in a zip and in the analysis form I have the two combobox fields that I would like to include...but the filters do not seem to work even though I have added it as per the instructions from the help file.

                I am wondering if you gurus are able to have a quick look at the analysis form and enlighten me how I can get it filtered based from another combo box.


                Many thanks.

                Wei-Yen

                Comment


                  #9
                  Re: Using Ajax in the Desktop Product

                  Thank you Peter and Selwyn for the explanations.

                  Peter, how would you go about getting the "+" signs to show up immediately as in the Alpha sample Selwyn gave? I just am curious as this is not needed at the moment.

                  I also tried adding another node to Selwyn's example and must not be thinking clearly enough tonight---looking at the Alpha script it sure seems like there wouldn't be a problem with an uneven node structure and wanted to see for myself.


                  Wei-Yen,
                  Did you attempt using Peter Wayne's first script for the combo box cascade scenario?? It uses xdialog ....are you perhaps wanting to do this with combo boxes on a form?? (sorry, but no time left tonight to open your example--almost 1 am here)
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: Using Ajax in the Desktop Product

                    Originally posted by MikeC View Post
                    Two somewhat different approaches and I cannot see right away why Peter Wayne's tree does not open with it ready to expand with a plus sign along each node until the node is placed in focus??....or vice-versa, why does the sample Selwyn gave start out the way it should with the tree ready to expand?
                    The difference is the initial value of the variable that supplies the tree data.
                    In Peters code the tree variable is initially set to the list of states and only the list of states. The data would look like
                    Code:
                    AZ
                    CA
                    CT
                    DC
                    etc
                    There is no child data so no need for the + symbol. Only when you give a state focus triggering the onchange event does the tree receive child data.

                    On the other hand the treelist variable in Selwyns example is initially populated with the state value plus a child value which is the function.The data looks like
                    Code:
                    AZ|{EXPAND=Expanding tree...}!expandState("AZ")
                    CA|{EXPAND=Expanding tree...}!expandState("CA")
                    CT|{EXPAND=Expanding tree...}!expandState("CT")
                    DC|{EXPAND=Expanding tree...}!expandState("DC")
                    and so on....
                    Since each state has a child of sorts the + symbol is displayed.
                    Tim Kiebert
                    Eagle Creek Citrus
                    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                    Comment


                      #11
                      Re: Using Ajax in the Desktop Product

                      Thanks, Tim, I didn't really understand why I didn't get the [+] marks myself, but since it's just cosmetic, and I'm design-challenged, I let it slip!
                      Wei-Yen: It looks to me as though your analysis form is based on a set in which the analysis is the parent and the other two tables are a child and a grandchild table. From what I can see you should base the form solely on the analysis table, since you're only using the other tables as lookup tables.
                      You also have major problems with the way you set up the "company name" field in pool owners.dbf. In your field rules you say the field is both the shop_id in pool shops and company name in pool shops. You can only fill the field with one of those; I suggest you make it the shop id. Also in the set structure for analysis, there should be a one-to-one link from the pool owner to the shop, not one to many, unless one pool owner is likely to be serviced by multiple shops.

                      Comment


                        #12
                        Re: Using Ajax in the Desktop Product

                        Wei-Yen,
                        I try not to use forms whenever I'm doing anything complicated -- it's easier for me to control the user when I use xdialog. Here's an xdialog that does what I think you want. You have to change the field rules in pool owners, though, and put the pool_shops.shop_id in the pool_owners.company_name field, as I discussed in the previous post:
                        Code:
                        poolShops=table.external_record_content_get("pool shops",\
                        "'{DATA='+Shopid-'}'+Company_Name","Company_Name")
                        shop=""
                        poolOwners=" "
                        owner=""
                        dim testdate as d=date()
                        dim analysisID as c=""
                        
                        result=ui_dlg_box("New Pool Analysis",<<%dlg%
                        {region}
                        {region}
                        Shop: |[%O={@@}%.30,5shop^#poolShops!chosen];
                        Owner: |[%O={@@}%.30,3owner^#poolOwners?shop\>""]
                        {endregion}|{region}
                        {sp=3}Analysis ID: |[.16analysisID];
                        {sp=3}Test Date: |[%DATE%.14testdate]
                        {endregion}
                        {endregion};
                        {lf};
                        <Save?analysisID\>"" .and. owner\>"" .and. testdate<=date()> <Cancel>;
                        %dlg%,<<%code%
                        if a_dlg_button="chosen" then
                            a_dlg_button=""
                            poolOwners=table.external_record_content_get("pool owners",\
                            "'{DATA='+Poolownerid-'}'-Last_Name-','+trim(First_Name)","Last_Name+First_Name",\
                            "Company_Name="+quote(shop))
                        end if
                        %code%)
                        if result="Save" then
                            ' save analysis - you have to write this code
                        end if

                        Comment


                          #13
                          Re: Using Ajax in the Desktop Product

                          Originally posted by Peter.Wayne View Post
                          In this example, of a simple 3-level structure of state->city->customer, Selwyn's code and mine produce the same result. If, however, you have a tree in which some branches end after 1 node, others 2, others 3, etc., then it's hard to use Selwyn's technique, because it depends on knowing in advance whether a node is a terminal node or not. I could be wrong on that, but I personally could never get the %X..{EXPAND} method to work on a lopsided tree structure with uneven branches.
                          Peter,

                          It is not obvious from the example Selwyn posted because all of the data retrieved is from the customer table so all parent nodes have a child node. However within each 'expand' function is provision to set the child node to <none> if there is no data to display. So this limits that branch of the tree to one node that informs that no more data is available.

                          Attached is a revised script that demos this. It is a revision of the code Selwyn posted and works against the Learning xdialog app or AlphaSports.
                          I have manually 'injected' the state of Alabama into the list. No cities will be found for it so <none> is displayed. I added a fourth node that lists invoice numbers for each customer. I changed the format of the data in the expandCities function. Now the function checks the invoice table to see if there are any records for the customer and if not does not append the expandInvoice function call to that node. Therefore that node has no child data and no expand symbol.
                          Code:
                          dim filterExpn as c
                          dim orderExpn as c 
                          dim contentExpn as c 
                          dim tablename as c 
                          
                          tablename = "customer"
                          contentExpn = "alltrim(bill_state_region)+'|{EXPAND=Expanding tree...}!expandState('+quote(alltrim(bill_state_region))+')'"
                          filterExpn = "bill_state_region<> '' .and.unique_key_value()"
                          orderExpn = "bill_state_region"
                          
                          dim treeList as c 
                          treeList = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
                          treeList = "AL|{EXPAND=Expanding tree...}!expandState('AL')" + crlf() + treeList
                          dim selected as c = ""
                          
                          'The enable expression for the OK button looks to see if the 'selected' variable starts with 'ID:'
                          'If so, then we know we are at an endpoint in the tree.
                          
                          dim flagOK as l = .f.
                          
                          ui_dlg_box("Select Customer",<<%dlg%
                          [%X;S=BLR;D="|"%.60,20selected^<treelist];
                          [30selected]<Show treelist var!show>;
                          {justify=right}
                          
                          <10&OK!ok?left(selected,4)="Inv:"> <Cancel>;
                          %dlg%,<<%code%
                          if a_dlg_button ="ok" then 
                              flagOK = .t.
                          end if 
                          if a_dlg_button = "show" then
                              a_dlg_button = ""
                              showvar(treeList)
                          end if
                          %code%)
                          
                          
                          if flagOK = .t. then 
                              ui_msg_box("","You selected invoice number: " + substr(selected,5))
                              
                          end if 
                          
                          
                          function expandState as c (state as c )
                          ui_yield()
                          dim filterExpn as c
                          dim orderExpn as c 
                          dim contentExpn as c 
                          dim tablename as c 
                          tablename = "customer"
                          contentExpn = "alltrim(bill_city)+'|{EXPAND=Expanding tree...}!expandCity('+quote(alltrim(bill_city))+')'"
                          filterExpn = "unique_key_value() .and. bill_state_region=" + quote(state)
                          orderExpn = "bill_city"
                          
                          expandState = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
                          
                          if expandState = "" then 
                              expandState = "<None>"
                          end if 
                              
                          end function
                          
                          
                          
                          function expandCity as c (city as c )
                          ui_yield()
                              
                          dim filterExpn as c
                          dim orderExpn as c 
                          dim contentExpn as c 
                          dim tablename as c 
                          tablename = "customer"
                          'contentExpn = "alltrim(lastname)+', ' + alltrim(firstname)+'|{EXPAND=Expanding tree...}!expandInvoice('+quote(Customer_Id)+')'"
                          contentExpn = "alltrim(lastname)+', ' + alltrim(firstname)+'|'+customer_Id"
                          filterExpn = "unique_key_value() .and. bill_city=" + quote(city)
                          orderExpn = "lastname"
                          
                          
                          expandCity = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
                          
                          if expandCity = "" then 
                              expandCity = "<None>"
                          else
                              expandCity = *for_each(tag,word(tag,1,"|")+ if(a5_get_records_in_query("Invoice_Header","Customer_Id="+quote(word(tag,2,"|")))>0,"|{EXPAND=Expanding tree...}!expandInvoice("+quote(word(tag,2,"|"))+")",""),expandCity)
                          end if 
                              
                          end function  
                          
                          
                          Function expandInvoice as C(CustId as C)
                          ui_yield()
                              
                          dim filterExpn as c
                          dim orderExpn as c 
                          dim contentExpn as c 
                          dim tablename as c 
                          tablename = "Invoice_Header"
                          contentExpn = "'{DATA=Inv:'+Invoice_Number+'}'+alltrim(Invoice_Number)-' - ' + dtoc(Date)"
                          filterExpn = "Customer_Id=" + quote(CustId)
                          orderExpn = "Date"
                          
                          expandInvoice = table.external_record_content_get(tablename,contentExpn,orderExpn,filterExpn)
                          
                          if expandInvoice = "" then 
                              expandInvoice = "<None>"
                          end if 
                          
                          End Function
                          Tim Kiebert
                          Eagle Creek Citrus
                          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

                          Comment


                            #14
                            Re: Using Ajax in the Desktop Product

                            Tim,
                            I did not make it clear what I meant by an unbalanced tree. What I meant is illustrated by, say, a directory structure, in which any node could be a terminal node--even one of the top nodes could be a file. I'm not saying it can't be done, but I could not use the {EXPAND} syntax to populate a tree in which the terminal node could be either at the top, one down, two down, or three down. Your use of a5_get_records in_query() would probably do it. However, doing so loses some of the benefits of the {EXPAND} syntax -- you're then doing a query on every node to check for child nodes. So in a directory structure in which, say, there are 30 children for a node, you're doing 30 queries just to see whether or not to put a [+] in front of each child node.

                            Comment


                              #15
                              Re: Using Ajax in the Desktop Product

                              Peter: Thank you very much for replying back to me. I will give this a go. May I ask where this code goes? As this part of the customer selection is only part of the analysis set. There is some calculations it does. But that is something else.

                              I am very grateful for the help. :D

                              Comment

                              Working...
                              X