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

Setting active row in list control programatically

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

    Setting active row in list control programatically

    I have a few list controls that are cascading.

    List1 = Sales Offices
    List2 = Subdivisions
    List3 = Lots
    List4 = Options

    When I select a lot it populates the list of options. Without having to navigate back to "Lots" to select another lot I created an injectible container and placed a lookup control in there. I have a dynamic filter that is working showing me the lots that are available for the sales office and subdivision. I want to when the user selects a new lot to set the active row in the "Lots" list so that the options for the newly selected lot appear. Can someone tell me how I can accomplish this?

    I was looking through the different methods. would something like the code below work? The syntax is not correct as it errors out. Any help is appreciated! I was going to use the OnChange event. Just not sure how to set the row. I didn't see a list action that would work.

    var lotNO = {dialog.Object}.getValue('LS_LOT');
    //refresh a List and set focus to a particular value in the List
    {dialog.object}.refreshListData('OPTIONS',{setFocusToValue: lotNO});

    #2
    Re: Setting active row in list control programatically

    Hey Josh,

    This is a bit difficult to follow. First, I don't think you need an injectable container... is this just for a control to hold a value so that you can re-use that value? If so, and all this is in one dialog, then use a dialog namespace variable... e.g. {dialog.Object}.__myCurrentLotNo = 123; Then you can do this... var lotNO = {dialog.Object}.__myCurrentLotNo;

    The rest I can't really follow.

    Comment


      #3
      Re: Setting active row in list control programatically

      David,

      Thanks for the reply. After looking at my post I can appreciate why it is hard to follow.

      The first thing I should point out is this...I am using list controls and the "Has Parent List" feature to create the cascading effect down to the Lot and Options lists.

      I left out a crucial part of the design of my ux. The lots list and the options list are in two separate tab panes. So when I activate the options pane the lots are no longer in view which is why I wanted to give the user the ability to change the lot from the lookup control in the injectible container that I've included in the options list header. Does this make more sense?



      I don't want the user to keep having to go back and forth if they want to look at options for another lot. I attached a screenshot to that might help explain it better also.ss1.pngss2.png
      Last edited by coleresources; 01-21-2015, 01:27 AM.

      Comment


        #4
        Re: Setting active row in list control programatically

        Ok thanks... that makes more sense.

        You have List control, listLots, with a dependent List control, listOptions, with each List control is a separate Tab Pane of a UX Tab Control. Instead of navigating back to Pane 1 to select a Lot in Pane 1, you want to use a dropdown control in Pane 2 showing a list of Lots, select one, update the current selected row in listLots with your dropdown selection, and then have the dependent List refresh based on the new listLots selection. Right?

        This is a tough one because in order to select a row in the Lot List control, you need to have a zero based row number. That number must come from your dropdown, but you don't really have it.

        There is a way to get it (generate it), but I don't know if you want to go through the trouble. Generally, here's what you need to do...

        1. Use a Textbox control, lookup, Edit-Combo for your dropdown. This will let you use an XBasic function to fill the dropdown.
        2. Create an XBasic function that will return a generated Row Number and selected Lot Number from your Lot table. This function will use a very specific Select statement to get your Lot numbers and generate a sequential row number.
        3. Return this character, crlf delimited, pipe delimited list to your Textbox dropdown. There will be 2 columns... RowNumber, LotNumber. The dropdown will return the RowNumber.
        4. The XBasic function and the Lot List control must be sorted the same
        5. Now you have a Row Number in your dropdown control.
        6. Select a row from the dropdown control, subtract 1 to make it zero based.
        7. Perform a .setFocus on the Lot List using the Row from the dropdown.
        8. Perform a ._listRefreshCascadingLists on the Lot List to refresh the Options list.

        Comment


          #5
          Re: Setting active row in list control programatically

          Doesn't sound too difficult. Thanks David

          Comment


            #6
            Re: Setting active row in list control programatically

            Here's the XBasic function that sets up the dropdown Textbox control. There's an assumption here that the generated row number from the sql select statement will match the existing row number in the List control. That could possible get you into trouble, but the theory isn't too bad.

            Code:
            function getCustTableRow as c (e as p)
            	
            'select @rownum:=@rownum+1 as 'rowno', c.FirstName as 'fn' from tblCustomers c, (SELECT @rownum:=0) as tblRow	
            
            'debug(1)
            
            dim cn as sql::Connection
            dim flag as l
            dim sqlStmt as c
            dim rs as sql::ResultSet
            dim args as sql::arguments
            
            flag = cn.open("::Name::Test")
            
            if flag then
            
            	sqlStmt = "select @rownum:=@rownum+1 as 'rowno', c.FirstName as 'fn' from tblCustomers c, (SELECT @rownum:=0) as tblRow;"
            	flag = cn.Execute(sqlStmt,args)
            	if flag then
            		rs = cn.ResultSet
            		dim firstRow as n = rs.Data("rowno")
            		dim dataRows as c = rs.ToString(-1,1,.f.,"|")
            		dataRows = "RowNo|Firstname" + crlf() + dataRows
            		getCustTableRow = dataRows
            	else
            		'there was an error - close the connection and exit
            		cn.Close()
            		dim msg as c 
            		msg = "Could not execute the query. Error reported was: " + cn.CallResult.text
            		msg = js_escape(msg)
            		dim jscmd as c 
            		jscmd = "alert('" + msg + "');"
            		getCustTableRow = jscmd
            		exit function
            	end if  
            
            else
            	'there was an error - close the connection and exit
            	dim msg as c 
            	msg = "Could not open the connection. Error reported was: " + cn.CallResult.text
            	msg = js_escape(msg)
            	dim jscmd as c 
            	jscmd = "alert('" + msg + "');"
            	getCustTableRow = jscmd
            	exit function
            end if
            
            cn.FreeResult()
            cn.close()
            	
            end function
            And then the javascript code for the onChange event of the Textbox dropdown...

            Code:
            var currCustRow = parseInt({dialog.Object}.getValue('ddTextLots')) - 1;
            {dialog.Object}.setValue('listLots',currCustRow);
            
            {dialog.object}._listRefreshCascadingLists('listLots');

            Comment


              #7
              Re: Setting active row in list control programatically

              David,

              Thanks for the head start. I am trying to set the values in the controls I created to filter my query as variables. The function prototype says that I have access to the e.rv "request variables.

              I tried

              dim e.rv.dirtycolumns.r1.nameOfMyControl but it tells me that the object does not exist.

              Should that work? I need to pass in that value as an argument to make sure the correct lots are returned.

              I used the debugger and it seems like the above should work??
              Last edited by coleresources; 01-21-2015, 07:54 PM.

              Comment


                #8
                Re: Setting active row in list control programatically

                Any idea if I should have access to the values in those controls?

                Comment


                  #9
                  Re: Setting active row in list control programatically

                  Are you trying to get the value of a control from within an Ajax Callback? Or trying to get the value of a Request Variable using e.rv from within an Ajax Callback?

                  Comment


                    #10
                    Re: Setting active row in list control programatically

                    How can I access the values of the controls that hold the salesofficeid and subdivisionid that I need to filter my query on? I attached a screenshot showing the way the lookup control is configured lotSelector.png. It is setup to use an ajax callback.

                    I've never used an xbasic function to create a dynamic list. With other xbasic functions I've created in conjunction with ajax callbacks I've been able to access the values of controls using e.dataSubmitted.NameOfMyControl but it doesn't look like that is possible here. I am not sure if I need to create the variables with javascript and pass them into my function?

                    This is what I see when I examine e in the debugger debugger.png

                    Should i be able to access the value in e.rv.dirtyColumns.R1.SOS_SOID?

                    Comment


                      #11
                      Re: Setting active row in list control programatically

                      You need values from your UX, essentially before the UX is rendered, in order to feed those values into an Ajax Callback which, in turn, feeds a dropdown. Is that right?

                      In this case I think you'd need to let the UX render, and then, in the client-side onRenderComplete, fire off an ajax callback, that dynamically populates your dropdown... as in Video D41.

                      This way... the UX is rendered... you've got values in SOS_SOID and SOS_SDID controls, and the callback can now access those values.

                      Comment


                        #12
                        Re: Setting active row in list control programatically

                        I am using the OnSelect row event in the LotList property to set the values of the salesofficeid and subdivisionid controls on my ux. So every time the user selects a lot the actionscript populates those controls.

                        I am just unsure how to access the values in those controls and convert them into arguments in my callback for my SQL query so that it returns ONLY the lots for the selected sales office and subdivision. This thread has taught me how deficient I am at explaining the problem in a clear/concise way. I will try the method you called out above. It doesn't seem like it should be necessary to use a different method but maybe I do not have access to those values within the method I am using.

                        Comment


                          #13
                          Re: Setting active row in list control programatically

                          I think I finally understand...

                          The Lots List depends on the prior 2 Lists... Sales Offices and Subdivisions.

                          Once you make a selection in the Lots List, the Options List data can render. Lots is a parent List to Options.

                          Now you're in the Options Tab, veiwing Optinos for the selected Lot.

                          But, you don't to change tabs just to select another Lot. So... you have a Dropdown List showing Lots. Here you can select a Lot from the Dropdown control, change the Lot List Selected Row and now have Options List refresh for the Lot selected.

                          The Lot List has 2 arguments set up (Sales Office and Subdivisions). This is how it's filtered.

                          So... in your Dropdown control, change the Lookup Definition, Load Data Method, to Ajax Callback. This loads the Dropdown data dynamically when the Dropdown is opened. When the callback is run you'll see variables that you can use like...

                          Code:
                          e.rv._state.__args_C_argstate
                          In my UX, I've created an argument in my "Lot" List name argState. e.rv._state.__args_C_argstate is the variable name available in the callback. So you can now do this...


                          Code:
                          	args.set("argState",e.rv._state.__args_C_argstate)
                          
                          	sqlStmt = "select @rownum:=@rownum+1 as 'rowno', c.FirstName as 'fn' from tblCustomers c, (SELECT @rownum:=0) as tblRow WHERE BILL_STATE_REGION = :argState;"
                          Those are my columns names, but this is the idea.

                          Comment


                            #14
                            Re: Setting active row in list control programatically

                            David,

                            Thanks for all of your help!

                            I have it working but I lose the grouping that I created in the list control when the onChange event fires. I was wondering if you know of a way to maintain it?

                            Comment


                              #15
                              Re: Setting active row in list control programatically

                              You lose the Grouping in the Lots List control when the dropdown onChange event fires?

                              Drop another button on your UX and in the onClick or Click event put this...

                              Code:
                              {dialog.object}._listRefreshCascadingLists('listLots');
                              See if that messes with your grouping.

                              What is the Lots list grouped by?

                              Comment

                              Working...
                              X