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

a5_treeTextToJSON Function - Anyone know how to use this??????

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

    a5_treeTextToJSON Function - Anyone know how to use this??????

    Has anyone used the UX Component - Tree control?

    It has the ability to use a function called a5_treeTextToJSON but as usual, no helpful documentation.

    The video goes as far as showing how to setup rather useless examples with static text but stops short of showing how to use the tree control with a database.

    #2
    Re: a5_treeTextToJSON Function - Anyone know how to use this??????

    here the xbasic code I use to populate one of my tree controls, pretty basic stuff

    Code:
    function xb3 as c (e as p)
    	dim cn as sql::Connection
    	cn.open("::name::latest")
    	sql = "select op_type, op from method_ops order by op_type"
    	cn.Execute(sql)
    	rs=cn.ResultSet
    	txt=rs.tostring(-1,-1,.f.,"|")
    	txt2=*tree_to_outline(txt,chr(9))
    	txt3=a5_treetexttojson(txt2)
    	
    
    	xb3 = txt3
    	cn.Close()
    end function
    you could of course use a where clause in the sql select statement to filter on a session variable as per your other thread about tree controls

    Comment


      #3
      Re: a5_treeTextToJSON Function - Anyone know how to use this??????

      From the v12 release notes: http://news.alphasoftware.com/v12pre...seNotesV12.htm

      a5_treeTextToJSON Function - Converts a 'tree' definition that is in the form of a crlf delimited list with tab indented values and converts into a JSON tree definition. For use with the Javascript Menu and Tree objects in the UX and Grid components.
      The UX component has a new Tree control. And the UX and Grid components have a new action in Action Javascript to display a menu.
      Both the Tree and the Menu objects are populated with a JSON string that defines the items in the tree/menu.
      This JSON string can either be defined at design time, or can be computed using an Xbasic function. The ability to define the JSON string using Xbasic is extremely powerful because it means that your tree and menu objects can be highly dynamic.
      The a5_treeTextToJSON() function is a helper function that you can use in your Xbasic code to generate the JSON definition for the tree or menu.
      The function takes a CRLF delimited list of values. Tab indents are used to indicate the level in the hierarchy.
      For example, here is a simple tree definition:

      MA
      Boston
      Back Bay
      Financial District
      Cambridge
      Harvard Square
      Inman Square
      New York
      New York City
      Midtown
      Wall Street
      Albany
      Ithaca

      Using the a5_treeTextToJSON() function, you can convert the definition this JSON
      [
      {
      html: 'MA',
      children: [
      {
      html: 'Boston',
      children: [
      {
      html: 'Back Bay'
      },
      {
      html: 'Financial District'
      }
      ]
      },
      {
      html: 'Cambridge',
      children: [
      {
      html: 'Harvard Square'
      },
      {
      html: 'Inman Square'
      }
      ]
      }
      ]
      },
      {
      html: 'New York',
      children: [
      {
      html: 'New York City',
      children: [
      {
      html: 'Midtown'
      },
      {
      html: 'Wall Street'
      }
      ]
      },
      {
      html: 'Albany'
      },
      {
      html: 'Ithaca'
      }
      ]
      }
      ]

      In the above example, the JSON that is generated does not have any additional properties, such as the icon to show for each item, or the onClick event.

      The text tree that you pass into the a5_treeTextToJSON() function can include a list of additional properties for each item. These properties are in the form of a JSON object (on a single line), as shown in the following simple example:

      dim treeText as c
      treeText = <<%txt%
      Alpha
      Alpha-1{icon: 'myIconA', onClick: 'alert("You clicked on Alpha-1");'}
      Alpha-2{icon: 'myIconB', onClick: 'alert("You clicked on Alpha-2");'}
      Beta{icon: 'myIconC', onClick: 'alert("You clicked on Beta-1");'}
      %txt%

      ?a5_treeTextToJSON(treeText)
      = [
      {
      html: 'Alpha',
      children: [
      {
      html: ' Alpha-1',
      icon: 'myIconA',
      onClick: function(dn) {alert("You clicked on Alpha-1");}
      },
      {
      html: ' Alpha-2',
      icon: 'myIconB',
      onClick: function(dn) {alert("You clicked on Alpha-2");}
      }
      ]
      },
      {
      html: 'Beta',
      icon: 'myIconC',
      onClick: function(dn) {alert("You clicked on Beta-1");}
      }
      ]


      Important: The indentation in the text string that is passed into the a5_treeTextToJSON function must use tabs, not spaces.

      Tip: When generating the crlf delimited string that is passed into the a5_treeTextToJSON() function, another useful helper function is the *tree_to_outline() function, which takes a string of data in this format:

      Ma|Boston|Back Bay
      Ma|Boston|Financial

      and turns it into an outline format, which is the format needed by the a5_treeTextToJSON() function.
      Frank

      Tell me and I'll forget; show me and I may remember; involve me and I'll understand

      Comment


        #4
        Re: a5_treeTextToJSON Function - Anyone know how to use this??????

        Lance/Frank,

        Thank you! I will study this code.

        Thanks!

        Comment


          #5
          Re: a5_treeTextToJSON Function - Anyone know how to use this??????

          I have worked through this and can make most things work.

          However the onClick and attributes are just not working for me.

          I am sure it is a simple syntax problem.

          This works

          { icon: \'cssIcon=fa fa-folder\' , collapsedIcon: \'cssIcon=fa fa-folder\', expandedIcon: \'cssIcon=fa fa-folder-open\' , initialState: "open", value: "Hello" }

          With the genie I can use the onClick event

          So onClick (Genie based) I have

          func(this.value);

          function func(txt){ alert(txt);} the alert returns "value" the variable "we".

          The JSON from the component is

          [
          {
          html: 'parent',
          value: 'we',
          icon: 'cssIcon=fa fa-glass',
          collapsedIcon: 'cssIcon=fa fa-folder',
          expandedIcon: 'cssIcon=fa fa-folder-open',
          onClick: function(dn) {func(this.value);}, // I cannot get this section to work when I build with xBasic.
          children: [
          {
          html: 'child',
          icon: 'cssIcon=fa fa-folder-open'
          }
          ]
          }
          ]




          Also I cannot get this to work when passing from the server.


          {icon: 'myIconA', onClick: 'alert("You clicked on Alpha-1");'}

          Comment

          Working...
          X