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

JSONform textarea control available?

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

    JSONform textarea control available?

    I'm experimenting with JsonForm control.
    Have seen the multiline textbox.
    But seems that the textarea control is missing (preferably with html editor)

    Any work around for this / creating a custom control / using embedded control?

    Thanks for any leads
    Ger Kurvers
    Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.5 - 9192-5707(testing)
    Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

    #2
    The JSONForm is a great addition to Alpha but it does have a few shortcomings. I am pretty sure/hope these will be rectified/added as time goes by.

    To get a look of a textarea in a JSONForm use a standard textbox, set it to multiline and then in its textbox properties set its style to something like height: 2in; optionally set its width here as well or use the width menu in the controlbar at the top.

    After using JSONForms since the day they were made available and ironing out some of the issues with Selwyn, I love them, there are still a few things that I still think do not quite work correctly (editcombo being one, but I have worked out a workaround for this pretty much like the early days of using them in standard UX components). I now have Viewboxes for displaying data in list format and JSONForms as the detail view for editing the data. At first it was daunting getting the viewbox to align the data with the JSONForm but when you realise the viewbox just produces the JSON you need to a) create the basis of the JSONForm b) have the data in JSON format to fill in the fields in the JSONForm and then c) the JSONForm can produce the JSON to use in the sql_insert() function it is all so easy to have a working very lightweight UX up in no time.

    Comment


      #3
      Originally posted by Lance Gurd View Post
      c) the JSONForm can produce the JSON to use in the sql_insert() function it is all so easy to have a working very lightweight UX up in no time.
      I have moved to sql_upsert. Very nice to use. One function to insert and update.
      Alpha may be the best tool working with json. What ever you have for example resultset, request variables, query strings, arrays you can always easily convert them to json and back. There is always some sort of function to do the job.

      Comment


        #4
        Originally posted by Lance Gurd View Post
        The JSONForm is a great addition to Alpha but it does have a few shortcomings. I am pretty sure/hope these will be rectified/added as time goes by.

        To get a look of a textarea in a JSONForm use a standard textbox, set it to multiline and then in its textbox properties set its style to something like height: 2in; optionally set its width here as well or use the width menu in the controlbar at the top.

        .........
        Thanks Lance, I agree and your suggestion alsmost works for me.

        I have only a problem in de JSONform when using the multiline textbox in an insidelist_beneath row detailview.
        When the control has focus, everything is ok.
        But when the control has no focus the content of the textbox is shown partly outside the control and the slider is missing
        See attached images.

        Can you help me to cure that?

        Thanks in advance!

        Attached Files
        Ger Kurvers
        Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.5 - 9192-5707(testing)
        Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

        Comment


          #5
          Yes, had not noticed that, that must be a bug and worth reporting. Easily repeated even the quick dialog - XDialog Format multiline text sample format example does not encapsulate the text correctly

          Comment


            #6
            Originally posted by kkfin View Post

            I have moved to sql_upsert. Very nice to use. One function to insert and update.
            Alpha may be the best tool working with json. What ever you have for example resultset, request variables, query strings, arrays you can always easily convert them to json and back. There is always some sort of function to do the job.
            Thanks for pointing this out, sql_upsert seems a good way to go, do you have an example you could share where it ascertains if there is a primary key or not, the documentation is a bit lacking

            Comment


              #7
              sounds like a fancy term for mySQL's on duplicate key update.
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #8
                Yes, KKfin triggered me also to investigate sql_upsert. The documentation worked for me:
                https://documentation.alphasoftware....20Function.xml
                Look at how to get lastInsertedIdentity

                To be complete all my steps:

                1. Create in Json form a save button to perform an ajax callback (see screenshot)
                2. define a gatherinfo() function for the xbasic function sql_upsert:

                Code:
                function gatherInfo() {
                
                var _fieldsValuePairs = {dialog.Object}.getValue('Persons_new_JF');
                _fieldsValuePairs = "_fieldsValues_Json=" + _fieldsValuePairs;
                //alert(_fieldsValuePairs); for testing
                return _fieldsValuePairs
                }​

                3. Create an xbasic function to perform the sql_upsert function:

                Code:
                function sql_upsert as c (e as p)
                dim cn as sql::Connection
                dim fieldsValuePairs as c
                dim primaryKey as c
                dim primaryKeyValue as N
                dim tableName as c
                dim result as p
                result.errorText = "" 'anders sql error als het goed gaat en het uitgevraagd wordt in de fouten informatie
                
                cn.open("::Name::CptDemo")
                tablename = "Kontpers"
                ''debug(1)
                fieldsValuePairs = e._fieldsValues_Json
                
                primaryKey = "Kontpers_volg_nummer"
                primarykeyValue = ""
                
                result = sql_upsert(cn,tablename,fieldsValuePairs,primaryKey,primaryKeyvalue)
                
                sql_upsert = alert(result.error + "Nieuw Kontpers_volg_nummer" + result.lastInsertedIdentity)
                
                cn.close()
                
                end function
                
                ​
                If Insert works works, result.lastInsertedIdentity has the new key

                I'm now testing how to give a javascript command back so that the created key is stored in another field of the JsonForm,
                Should be piece of cake, but it is a long time ago that i wrote the correct syntax for that :-)
                Attached Files
                Ger Kurvers
                Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.5 - 9192-5707(testing)
                Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

                Comment


                  #9
                  Thanks for this, however I still do not understand how the sql_upsert() method gets the primarykeyvlue when editing an existing record.

                  Comment


                    #10
                    Originally posted by Lance Gurd View Post
                    Thanks for this, however I still do not understand how the sql_upsert() method gets the primarykeyvlue when editing an existing record.
                    Indeed, for testing I hardcoded it in the example.

                    But I have the primary key in the JSONFORM component (hidden - display none:-) and not Updateble.
                    I set its value when loading the component and use an argument or a state variable for that.

                    But you know what the primary key is. So, if you only write back for update the dirty fields than you can pass them in as extra variables with the gatherInfo() function.
                    If you write to the server all fields of the JSONFORM, than you can grab them in xbasic from e._fieldsValues_Json variable (don't ask the syntax, I have to rediscover that also :-)

                    My usecase is: I have a persons table with persons-id as key and phone/mail/fax table. with telfax_id as key, Both keys are autoincrement ofcourse.

                    When defining them I use 1 or 2 jsonform, totally unbound, in an unbound ux
                    Users wil be able to specify both person and contact details (multiple detailrecord) without saving in between

                    I want to create1 update button with 2 sql_upsert actions in a begin-end transaction proces.
                    After persons details are stored I grab the lastInsertedIdenty and store that as linking field in the second sql_upsert for telfax table.

                    That is the plan. When everything works I can share the code if somebody is interested, but i guess it will take a while.

                    Last edited by cptutrecht; 12-06-2023, 03:12 PM.
                    Ger Kurvers
                    Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.5 - 9192-5707(testing)
                    Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

                    Comment


                      #11
                      Finally worked out the correct syntax for sql_upsert()

                      I used
                      Code:
                      dim lsjson as c=e.dataSubmitted.JSForm [COLOR=#3498db]'JSForm is the name of my JSONForm on the UX[/COLOR]
                          dim sql as p
                          dim flag as l
                          dim cn as sql::connection
                          dim js as p
                          js=json_parse(lsjson)
                      
                      
                          flag = cn_open(cn,"::Name::Jobs")
                      if flag = .f. then
                          'there was an error
                          dim errorText as c
                          errorText = cn.callresult.text
                          end
                      end if
                      'turn on portable SQL
                      cn.PortableSQLEnabled = .t.
                      sql=sql_upsert(cn,"job_labour_details",lsjson,"JOBSHEETNO",js.JOBSHEETNO) [COLOR=#3498db]'JOBSHEETNO is the primary key of the table job_labour_details[/COLOR]
                      savelsheet="{dialog.object}.refreshViewBoxData('jobsheets');" [COLOR=#3498db]'Refreshes the viewbox "List"[/COLOR]
                      cn.Close()
                          ​
                      And this all works seamlessly if you are saving a new record js.JOBSHEETNO is empty and a new record is created, if js.JOBSHEETNO has a value it knows you are editing a record and therefore saves that record.

                      This is a great command and saves a lot of long winded if statements that test if you need to use sql_insert or sql_update and also saves a lot of setting each value from a standard form to an argument value in the more traditional method of saving/updating sql tables

                      Comment

                      Working...
                      X