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

Populate a List Control's Detail View Programmatically

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

    Populate a List Control's Detail View Programmatically

    I have a List control that is populated with an ajax callback, as in this video: http://www.alphasoftware.com/video-l...ol&search=list

    But using this method does not populate the detail view controls.

    {dialog.Object}.getValue('list::List1::Name'); does not return a value.

    Is there a way to populate the detail view controls in this scenario?

    #2
    Re: Populate a List Control's Detail View Programmatically

    Is your Detail View Data Mapping set up?
    Details view controls are populated as a row is selected in the List Control. You may not be seeing a value because you may not be selecting a row.
    After a row is selected, the Detail View controls are populated and you can then use .getValue() on the Detail View control. You don't have to go through the List to get that value.

    Comment


      #3
      Re: Populate a List Control's Detail View Programmatically

      Yes, the Detail View field mapping is set up. The list can be populated be populated using the sql query in the list control builder, and the detail view is populated.

      In the same UX I have events that populate the same list with an xbasic function. The list populates correctly, but the Detail View fields do not get populated when a row is selected.

      Comment


        #4
        Re: Populate a List Control's Detail View Programmatically

        Ok... there's a bit more info now that was missing from the first post. You're loading the List Control, data bound, from a SQL Source... and... using the same List control to manually populate from SQL using an ajax callback.

        I took the sample UX from the video you referenced, added a detail view, and a SQL Data source... and, as long as the data column names are correct for both... all is good. The Detail View gets populated from each source upon row selection.

        You'd need to post an example where it isn't working... along with the table you're using.

        Comment


          #5
          Re: Populate a List Control's Detail View Programmatically

          I found my mistake.

          I had modified the SQL statement in the builder, and not made the same changes to the ajax callback. Too many hours at the computer.

          BTW, where did you find the sample UX from the video?

          Comment


            #6
            Re: Populate a List Control's Detail View Programmatically

            Figured it was something like that. Have a look in the release notes... the sample UX is there with the videos.

            Comment


              #7
              Re: Populate a List Control's Detail View Programmatically

              I have another issue when populating a list control with an ajax callback.

              Again, I have a UX with a list control call Loads_List.

              The list control has a sql statement that can populate the list, and an ajax callback that can populate the list.

              The list control is set to return the primary key: Load_ID

              When populated from the data bound sql statement, it returns the primary key for the selected row.

              When populated with the ajax callback, the primary key is "undefined".

              In working preview, it throws this error:

              Load_ID_error.png

              How can I get the list to return the primary key when populated via the ajax callback?

              Here is my function...


              Code:
              function populateLoadsList as c (e as p)
              	
              	dim js as c
              	dim flag as l
              	dim sql as c
              	dim cn as sql::Connection
              	dim args as sql::Arguments
              	dim rs as sql::ResultSet	
              		
              	flag = cn.open("::Name::FreightzoneMySql")
              		if flag = .f. then 
              			js = "alert('Could not connect to database. Error reported was: ' + '" + js_escape(cn.CallResult.text) + "');"
              			GoTo endpopulateLoadsList
              		end if
              	
              	sql = <<%txt%
              	SELECT DISTINCT loads.Load_ID, loads.FreightBillNum, loads.ShipFrom, loads.DeliverTo
              	FROM loads
              	WHERE loads.`Status` = 'Booked'
              	ORDER BY loads.FreightBillNum
              	%txt%
              	flag = cn.execute(sql,args)
              		if flag = .f.
              			js = "alert(populateList cn.execute(sql,args)ONE failed.');"
              			goto endpopulateLoadsList
              		end if		
              
              	dim rs as sql::ResultSet
              	rs = cn.ResultSet
              
              	dim json as c
              	json = rs.ToJSONObjectSyntax()
               	json = stritran(json,crlf(),"," + crlf())
              	json = "[" + rtrim(json,",") + "]"
              
              	js = js + "var lObj = {dialog.object}.getControl('Loads_List');" + crlf()
              	js = js + "var _data = " + json + crlf()
              	js = js + "lObj.populate(_data);"
              
              
              endpopulateLoadsList:
              
              populateLoadsList = js
              
              cn.FreeResult()
              
              delete rs
              
              cn.Close()		
              end function

              Comment


                #8
                Re: Populate a List Control's Detail View Programmatically

                You have no debug statements in your XBasic function. You need to walk through your code and see that it's failing. You have too many specific and logical errors in your code.

                You're executing sql with args but not setting args. That's not horrible... but why do it. You're using a goto where you don't need to... just clean up and exit. Your goto goes to a section were you delete a rs you don't have. XBasic doesn't mind, but why do it.

                This part of the sql statement is causing the function to fail...

                WHERE loads.`Status` = 'Booked'

                Your "tick" marks around Status are not needed and are causing an error. You actually don't need the table name prefix either. I use %txt% on long statements but not so much on anything I can see on a line. This statement would do nicely...

                Code:
                sql = "SELECT DISTINCT Load_ID, FreightBillNum, ShipFrom, DeliverTo FROM loads WHERE Status = 'Booked' ORDER BY FreightBillNum"
                If your sql execute fails (and it does)... you set an returning js Alert which is badly formed. You're missing an opening single quote. It should be...

                Code:
                js = "alert('populateList cn.execute(sql,args)ONE failed.');"
                Again... have a look at the sample UX. It has no issue utilizing a data bound List and a List populated with an Ajax Callback. I get no errors.

                If you want to post a sample UX with your table I'll have a look.

                Comment


                  #9
                  Re: Populate a List Control's Detail View Programmatically

                  My original code was more complex. I simplified it for testing, and posted the simplified version. I ran it with the code I posted and got the same error.

                  The tick marks are because Status is a reserved word in MySql. The query fails without the tick marks.

                  In the video he uses a static data source. I have tried that with the same result.

                  I have not found the sample UX at http://downloads.alphasoftware.com/A...easenotes.html

                  I would like to have the sample to compare.

                  Comment


                    #10
                    Re: Populate a List Control's Detail View Programmatically

                    Since you're having trouble finding it, the sample UX from the Release Notes is attached. Doing a search for 'populate' in the release notes will eventually get you to the sample UX. Also attached is a sample UX using a sample "loads" table with my Connection String named "Test" - so you'll need to change that in the UX.

                    Although I would not use a reserved word as a column name, using "Status" doesn't seem to hurt anything. This MySQL statement (now that we know you're using MySQL) returns data without error...

                    Code:
                    sql = <<%txt%
                    SELECT DISTINCT Load_ID, FreightBillNum, ShipFrom, DeliverTo
                    FROM loads
                    WHERE Status = 'Booked'
                    ORDER BY FreightBillNum
                    %txt%
                    Here are before (static) and after (dynamic) callback images. No errors, no issues.

                    ListStatic.PNGListDynamic.PNG


                    dynamicallyPopulateListLoads.a5wcmp
                    dynamicallyPopulateList.a5wcmp
                    Last edited by Davidk; 11-26-2016, 05:02 PM.

                    Comment


                      #11
                      Re: Populate a List Control's Detail View Programmatically

                      I will look at everything you suggest.

                      And yes, the MySQL statement in the builder and the ajax callback both return data and populate the list correctly.

                      The issue is that in the list builder, the "Return Value Type" is set to "Primary Key".

                      When populated from the MySQL statement in the builder, it successfully returns the primary key.

                      This will alert the primary key for the selected row:

                      Code:
                      var _val = {dialog.Object}.getValue('List1');
                      alert(_val);
                      However, after populating the same list from an ajax callback, the alert returns "undefined".

                      Comment


                        #12
                        Re: Populate a List Control's Detail View Programmatically

                        Ok... now we got something solid to go on. For some reason the *value property of the List data object is not being set on an ajax callback. Have to look into that one.

                        For now... change the method you're using for getting the Id. The following will return the Load_ID for both the SQL and Ajax Callback.

                        Code:
                        var _val = {dialog.Object}.listGetValue('list1','Load_ID');
                        alert(_val);

                        Comment


                          #13
                          Re: Populate a List Control's Detail View Programmatically

                          In order to populate the fields in the detail view, the List control must return the primary key.

                          Comment


                            #14
                            Re: Populate a List Control's Detail View Programmatically

                            Ok... back to Detail View. You want to update and sync the row as well... after the List is based on the Ajax Callback data?

                            Comment


                              #15
                              Re: Populate a List Control's Detail View Programmatically

                              Yes. I want to....

                              Populate the detail view controls when a row is selected.

                              Perform a client to server sync for the selected row, when a button is clicked.

                              Prevent navigation if any detail view control is dirty.

                              I also need to populate a child list when a row is selected. For this I don't need the list control to return the primary key.

                              Of course, if the list could return a primary key, all these actions are easy to do. Also, I want to use the method of populating list controls with an ajax callback in other UXs.

                              Overall, the goal is to convert many UXs to be list based, instead of using data binding in the UX.

                              This exercise is the first attempt to do so.

                              I thought that regardless of whether a list control is populated with a sql query or an ajax callback, all the functions and features of the list control would be available. In fact, returning the primary key is the only item I have found that does not work, although there are functions that don't work because they require the primary key.

                              If I specify that the list control returns a field from from the table, the value of the field is correctly returned. Since the primary key is available, I would think it should be returned.

                              In fact if I specify that the list control returns a field from from the table, and set the field name to the name of the primary key field (in this case Load_ID), the correct value is returned. However, in order to populate detail view controls, the list builder forces the Return Value Type to be set to Primary Key.

                              Maybe this is a bug?

                              Comment

                              Working...
                              X