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

Printing checked rows

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

    Printing checked rows

    Does anyone know how to print the checked rows in a grid, similar to the filterCheckedRows method?

    So, I have the checkbox column turned on and an action button in the grid toolbar that calls a report. From there I don't know how to define the filter so it will print only the selected rows.

    Any ideas?
    - Dan Hooley
    - Custom Desktop or Web database development -

    #2
    Re: Printing checked rows

    Dan -

    If you use, say, an action button to run a callback, start with this in your callback:

    Code:
    CheckCount = val(e.checkboxRows.countChecked)
    check_list = ""
    if CheckCount > 0
    	check_list = extract_all_strings(e.checkboxFilterArgumentXML,"<Data Type=\"C\">","</Data>",crlf(),.f.)
    end if
    check_list, in this case, will contain a crlf()-delimited list of the keys that were checked. Also note in this example the keys are Data Type = "C" and yours may well be numeric type.

    With that list in hand, there are a few ways to create a SQL filter.

    One I use most is to convert the crlf() list:

    Code:
    check_list = crlf_to_comma(check_list)
    then use this to construct a SELECT statement

    Code:
    sql = "SELECT . . . . WHERE ID IN('" + check_list + "')"
    When using the IN() clause for your SELECT statement, be aware that A5 portable SQL mostly doesn't know what to do with that clause, so set portableSQL off when you execute that.

    I think this'll get you started.
    -Steve
    sigpic

    Comment


      #3
      Re: Printing checked rows

      Thanks, Steve

      Yea, I can assemble the list of ID's no problem (can even do it in js), but how to get that list into the filer expression of the action that opens the report, in a format that it understands??

      If I hard code the filter expression to something like: OrderID IN (1020,1022,1031,1050) it works. (and yes, my primary key is numeric)
      but, if I assemble those same ID's and put them in an argument (has to be character and probably the problem) and then reference the argument like: OrderID IN (:whatIDList) it doesn't work!

      Or, can I open a report from a callback like you started?
      - Dan Hooley
      - Custom Desktop or Web database development -

      Comment


        #4
        Re: Printing checked rows

        Dan, here's how to handle your filter expression.
        Study this attached image.
        Clipboard01.jpg
        The JobIDList_Dummy is a local argument created using that "Define Arguments" button. It is not actually in the report, but the other 2 arguments are in the report for title display purposes only (nothing to do with the report's query).
        Note the SQL Filter contains the IN statement.
        Note there is reference to a Before execute event (javascript).

        I define a function called beforeUserSelectReportRuns to swap the dummy argument with a list of IDs.
        Code:
        function beforeUserSelectReportRuns(ro) {
        	var data = '';
        
               //your list goes here.....
        	data = {Grid.Object}.harvestColumn('JOBID',',');
        	//data = '1005,1026,1037';
        
        	if(_AG_setArgumentValue(ro, 'JobIDList_Dummy', data)) {
        		//alert('yea');
        	}
        }
        And this function does the actual replacement:
        Code:
        function _AG_setArgumentValue(ro, argName, argValue) {
        
        	//ro.sqlFilter = 'dbo_Jobs.JobID IN (:JobIDList_Dummy)';
        	//ro.sqlOrder = 'dbo_Jobs.BQ_ProjectName';
        	//ro.arguments = 'MyEmpCode|Character|SESSION.USERCODE||MyTitle|Character|Report - Selected Entries||JobIDList_Dummy|Character|1005,1026,1037';
        
        	argName = ':' + argName;
        
        	if(typeof ro == 'undefined') return false;
        	var myfilter = ro.sqlFilter;
        	var newfilter = '';
        
        	if(myfilter.indexOf(argName)<0) return false;
        
        	if(argValue.length>0) {
        		newfilter = myfilter.replace(argName, argValue);
        		ro.sqlFilter = newfilter;
        		return true;
        	}
        	return false;
        }

        So this should work for you. Good luck.

        Comment


          #5
          Re: Printing checked rows

          hello

          this is how i did it and just checked, it works.
          place two buttons on the grid,
          first one name it " select to print" and the on click event define in text mode - {grid.Object}.filterCheckedRows(); use this to select after selecting the records.
          second one name it "print" and on the on click event define an action javascript and select print report and fill in name of the report and the next line fill in "currentGridFilter()"
          it will work as expected, at least here it does. please see my version number and build in case you need to know and i use mysql.
          only problem i know about this method of printing using check boxes is--
          say you have turned on check boxes and selected multiple pages in the check box property and happily you go about selecting few here and few in the next page and want to print it will only print the visible page items, however if you click the button that says all on the top ( i use quicksearch also in the grid) then it will show all the selected records and it will print.
          is this you are looking for?
          since then i have moved on to better selection of the records, which is what i am using now. not the check boxes any more.
          Last edited by GGandhi; 01-23-2013, 09:37 PM.
          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: Printing checked rows

            Originally posted by danh View Post
            Thanks, Steve

            Yea, I can assemble the list of ID's no problem (can even do it in js), but how to get that list into the filer expression of the action that opens the report, in a format that it understands??

            If I hard code the filter expression to something like: OrderID IN (1020,1022,1031,1050) it works. (and yes, my primary key is numeric)
            but, if I assemble those same ID's and put them in an argument (has to be character and probably the problem) and then reference the argument like: OrderID IN (:whatIDList) it doesn't work!

            Or, can I open a report from a callback like you started?
            Is this a MySQL database? You cannot use IN with numeric fields in MySQL! It will only compare everything up to the first comma and never look at the remaining list in your argument. I got bit by this recently. Use FIND_IN_SET. This post was super helpful: http://stackoverflow.com/questions/4...d-in-set-vs-in
            Alpha Anywhere latest pre-release

            Comment


              #7
              Re: Printing checked rows

              Andy,

              Your solution works! I did not see the beforeExecute event and not sure I would have known how to use it if I did. I had already figured out how to assemble the list of ID's so it was an easy task to finish it up.

              Thank you very much!!

              Is this a MySQL database? You cannot use IN with numeric fields in MySQL! It will only compare everything up to the first comma and never look at the remaining list in your argument.
              And Sarah, yes it's a MySQL database. That's true if you are using a character argument type against a numeric field. And you can't really use any other type, because it's a string.
              But, this will work, even if the OrderID field is numeric: OrderID IN (1021,1022,1023,1024)
              That's where Andy's function comes it.

              However, FIND_IN_SET looks interesting too. I will do some more testing.
              I've got some good answers! Thanks to everyone!
              - Dan Hooley
              - Custom Desktop or Web database development -

              Comment


                #8
                Re: Printing checked rows

                Originally posted by danh View Post
                And Sarah, yes it's a MySQL database. That's true if you are using a character argument type against a numeric field. And you can't really use any other type, because it's a string.
                But, this will work, even if the OrderID field is numeric: OrderID IN (1021,1022,1023,1024)
                That's where Andy's function comes it.

                However, FIND_IN_SET looks interesting too. I will do some more testing.
                I've got some good answers! Thanks to everyone!
                Ahhhh. I didn't catch that you were having trouble populating :whatIDList.

                Well, at any rate...

                WHERE FIND_IN_SET(OrderID, :whatIDList) (MySQL; non-portable; works for all data types)
                WHERE OrderID IN :whatIDList (portable; may or may not crap out on you)
                WHERE :whatIDList CONTAINS OrderID (portable; irritates A5 SQL Genie)

                NOT IN is valid in Portable SQL syntax. I don't see why IN wouldn't be supported?

                Of course, if you could find some other solution than using FIND_IN_SET for searching IDs, that'd probably be idea. The algorithm is slower than doing a long EQUAL/OR string: "ID = :val1 OR ID = :val2 OR ID = :val3 . . ."

                I've been doing some extra searching today...
                Alpha Anywhere latest pre-release

                Comment


                  #9
                  Re: Printing checked rows

                  I used GGanhi's method of two buttons (Filter Checked Records) and a Print Icon that calls a menu of reports that are all filtered by CurrentGridFilter(). The result is great as it then allows my users to print any number of reports from the resulting filtered records. This also means that they can export to Excel only those records they checked and filtered. Thanks, GGandhi!

                  I use a custom search UX form and embedded the grid so I added the following inline Javascript to both my Search and Clear Search buttons to clear out any residual checkmarks and filtered records:

                  {dialog.EmbeddedGrid_GRDPROPERTIES}._selectAllRowCheckboxes(false);

                  GRDPROPERTIES is the alias I assigned to my embedded grid. This allows for a very customized search form and a really nice option for clients to search and then filter down their results.
                  Brad Weaver, President
                  ComputerAid International
                  Ottawa ON Canada
                  Versailles KY USA
                  www.compuaid.com

                  Comment


                    #10
                    Re: Printing checked rows

                    I am trying to follow Andy's method in post #4 above to set a filter for a report in V-12. Everything seems to be working except I can not figure out how to get the ro argument value in the first function "function beforeUserSelectReportRuns(ro) {" I think this is a reference to the report object but I can't find a way to set it. I am calling this from the Client-side Grid System Events - (afterAjaxCallbackComplete)

                    Any thoughts would be greatly appreciated.
                    Thanks, Rod

                    Comment


                      #11
                      Re: Printing checked rows

                      Hi Rod,
                      Check the image that I had posted. You should see "beforeUserSelectReportRuns" listed as a event-driven function to be call - it is in the action javascript edit window near the bottom.
                      The "ro" argument gets passed automatically (by default, as the report object) to whatever function name you place there.
                      You are free to name it whatever you wish.
                      Good luck.
                      Andy.

                      Comment


                        #12
                        Re: Printing checked rows

                        Andy,

                        Thank you so much, sometimes I need a 2x4 upside the head to see what’s right in front of me. I had studied that image at least a dozen times but had not seen the “Before Execute Event”. I am now dealing with another issue but would never have moved on to this new problem without your help.

                        Thanks again, Rod

                        Comment

                        Working...
                        X