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

setValue in list doesn't work on button.

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

    setValue in list doesn't work on button.

    Hi Experts,

    I have a list LIST1 contains 1 column youranswer and 1 button.

    I would like to set youranswer value to Yes when click on the button.

    But I cannot see any changes on youranswer after click the button.

    The code inside the button...
    Code:
    {dialog.object}.setValue('list::LIST1::answer', 'Yes');
    Is it anyway to make it work?

    Thanks,
    Regards.
    Last edited by wei243; 11-25-2016, 04:41 AM.

    #2
    Re: setValue in list doesn't work on button.

    'LIST::LIST1::answer', 'Yes' - use Ucase.. and see what happens
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

    Comment


      #3
      Re: setValue in list doesn't work on button.

      Case does matter, but in a completely different manner. You can't use .setValue() on a List control in the way you're using it. The List Control is a data control, and so it's "value" is the "Return value type"... usually PrimaryKey or a Field Name. When you use .setValue() on a List, you're selecting a row (or rows)... not setting the value of a column.

      There's a lot of information missing from your question... but let's say you have a simple read only List, no Detail View, and you want to change the value of a column in a row. You've not said anything about updating a database so I won't consider that.

      Get the List Object, then use .updateRow() on that object. You'll need to know either the row number or the List key value (if the List is configured to return the Primary Key).

      Code:
      var listObj = {dialog.object}.getControl('list1');
      listObj.updateRow(3,{youranswer: 'Yes'});
      It does not matter what case you use for list1, but case does matter when referring to your column name - it must match your List column name.

      This code only updates the data displayed in the List control for the 3rd row (zero based). It has no effect on the SQL Table.

      Code:
      listObj.updateRow('167',{youranswer: 'Yes'});
      With the List set to return the Primary Key, this would update the row with the Primary Key value of 167.

      If you want to update a table, then your List would have a Detail View and you'd update the List and table through the Detail View controls.

      Comment


        #4
        Re: setValue in list doesn't work on button.

        This is probably a similar question as it has to do with setting the value of a field in a clicked on row.
        I have an image in my list control. When a user clicks the image I want to evaluate the value and change the value of another field. Heres the javascript code I want to edit to work in this context.
        Code:
        var nope = "No";
        var tic = {dialog.object}.getValue('tasks_is_complete');	
        Switch(tic){
        	case 'Yes':
        		{dialog.object}.setValue('tasks_is_complete',nope);
        		break;
        	case 'No':
        		{dialog.object}.setValue('tasks_is_complete','Yes');
        		break;
        	case 'Reminder':
        		{dialog.object}.setValue('tasks_is_complete',nope);
        		break;
        	case 'Flag':
        		{dialog.object}.setValue('tasks_is_complete',nope);
        		break;
        }
        Ok, so that's how I would do it if this were in the onchange event of a typical field but this is an image field called 'grpimage'
        The onclick event for an image says that I must reference "data.fieldName" to reference the list controls current row data.

        Can someone tell me how I can convert my code to work in this context?
        I tried 'data.tasks_is_complete' to refernce the setValue field but that didnt work.
        not sure of how to make a click event work on an image field.
        tasks_is_complete is an adjacent field to the image which is a conditional image based on tasks_is_complete btw.

        The idea would be the user taps (clicks) on the image and then sets the status to No
        The end goal would be to save the value as well with the click, im just working through the first steps.
        NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

        Comment


          #5
          Re: setValue in list doesn't work on button.

          this has nothing to do with what you are looking for but the code can rewritten as
          Code:
          var nope = "No";
          var tic = {dialog.object}.getValue('tasks_is_complete');	
          Switch(tic){
          	       case 'No':
          		{dialog.object}.setValue('tasks_is_complete','Yes');
          		break;
          
                         case 'Yes':
          	       case 'Reminder':
          	       case 'Flag':
          		{dialog.object}.setValue('tasks_is_complete',nope);
          		
          }
          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


            #6
            Re: setValue in list doesn't work on button.

            I've read your post a few times but it isn't getting any clearer. You have a List control with a conditional image field. That conditional image field is based on another field in the List... "tasks_is_complete".

            You want to click that image field and change the value of the List field "tasks_is_complete".

            If "tasks_is_complete" is "No", then change it to "Yes"... else change it to "No".

            Changing the List field value of "tasks_is_complete" results in an automatic change of the conditional image.

            Is this what you want?

            Comment


              #7
              Re: setValue in list doesn't work on button.

              don't you have to finish with "break;" before the closing } ?
              NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

              Comment


                #8
                Re: setValue in list doesn't work on button.

                David that is exactly right
                NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                Comment


                  #9
                  Re: setValue in list doesn't work on button.

                  So I looked at the xbasic generated it's as follows:
                  Code:
                  dynamicImage.onClick = <<%str%
                  var nope = "No";
                  var tic = {dialog.Object}.listGetValue('tasks','tasks_is_complete');	
                  Switch(tic){
                  	       case 'No':
                  		{dialog.object}.setValue('tasks_is_complete','Yes');
                  		break;
                  
                             case 'Yes':
                  	       case 'Reminder':
                  	       case 'Flag':
                  		{dialog.object}.setValue('tasks_is_complete',nope);
                  		
                  }%str%
                  so just like the conditional image itself it needs to be in string format - this is where I am lost as how to write it. The help section does say to use data.fieldName
                  soooo, it could be like this?
                  {clientSide}data.tasks_is_complete=='Yes'|{dialog.object}.setValue('tasks_is_complete','No');
                  Last edited by CharlesParker; 08-06-2017, 11:31 AM.
                  NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                  Comment


                    #10
                    Re: setValue in list doesn't work on button.

                    I think you're getting wrapped around the axle a bit.

                    If what you're presenting is actually what you want to do, then a "switch" statement isn't really needed. You're showing a simple if...then...else... process. If No then change the value to Yes... anything else change the value to No.

                    The Dynamic Image in the List control has an OnClick event. And a "Stop event propagation" property. If your List has onClick or onSelect, etc. event code, then you'll need to decide if you want to stop propagation is the Image OnClick event. That's up to you.

                    The code for the Image OnClick event is...

                    Code:
                    var tic = data.tasks_is_complete;
                    if(tic=='No'){
                    	listObj.updateTableRow(rowNumber,{tasks_is_complete: 'Yes'});
                    }else{
                    	listObj.updateTableRow(rowNumber,{tasks_is_complete: 'No'});
                    }
                    The OnClick event provides 'listObj' - a pointer to the List control... and 'data' - a JSON Object of that row's data.

                    You'll need to turn on the List property 'Has Detail View'... but you don't need to add any Detail View Controls.
                    You'll need to add a Synchronize button... or automatically sync the changes back to the table.

                    Comment


                      #11
                      Re: setValue in list doesn't work on button.

                      Ok, interesting. I did read the "updateTableRow" methods a little while ago and wondered if that was the way to go, but not knowing would've been a huge dart thrown in the dark for me.
                      I do have a detail view and syncs auto so that should work out. I will try to figure out the stopped prop on the click event and post back. Thanks for the advice, I wonder sometimes though how the hell you know all of this, nevertheless, I am REALLY glad you are such an active part of the community.
                      ~Cheers
                      NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                      Comment


                        #12
                        Re: setValue in list doesn't work on button.

                        Ok, so that is working quite nicely - of course, I have other edits now that I have the method. When the status is changed to "Yes" meaning the task is complete, I also update the calendar color which is also a else if scenario based on other fields (calcolor1 and calcolor2).
                        This is actually a calendar event using Jims Calendar that changes color based on the status. Users can look at their calendar and quickly see the status by color, however when a tech is in the field he gets an Agenda (List) that he can just tap the image to mark as complete, if he wants to create a report or add images etc he can go to the detail view with a double tap.
                        I think it would be really helpful if AS would include a code snippet in there, such as what you provided. I think I can figure it out now.
                        NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                        Comment


                          #13
                          Re: setValue in list doesn't work on button.

                          So far this is what I have:

                          Code:
                          var tic = data.tasks_is_complete;
                          if(tic=='No'){
                          	listObj.updateTableRow(rowNumber,{tasks_is_complete: 'Yes'});
                          	{dialog.object}.saveListEdits('TASKS',{rows: 'current'});
                          }else{
                          	listObj.updateTableRow(rowNumber,{tasks_is_complete: 'No'});
                          	{dialog.object}.saveListEdits('TASKS',{rows: 'current'});
                          }
                          This works great, as DK pointed out you might want to sync the edits! Since I did not know the correct syntax for that, I just let Alpha create the button to sync then copied the code.
                          NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                          Comment


                            #14
                            Re: setValue in list doesn't work on button.

                            Originally posted by CharlesParker View Post
                            don't you have to finish with "break;" before the closing } ?
                            The point was not that
                            You have same end point for 3 options if so you don't need to write them out separately you can list as I did
                            And you don't need break for the last statement since it will fall off after that.
                            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: setValue in list doesn't work on button.

                              Ok, just asking. As you can see, I had my head wrapped around the axle as DK said anyways AND this has been sorted. I also think it will help others out as the help section in that area really doesn't explain it near as well as DK did in his example. Thanks for the expert adive on the JS though as well because I actually write the whole thing out every time.
                              NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                              Comment

                              Working...
                              X