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

Set grid filter OnInialize, then clear on search

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

    Set grid filter OnInialize, then clear on search

    Given a MySql datetime field named "Updated", I want to have the grid load just showing today's records.

    Putting this in the grid query does this:

    DATE(Updated) = curdate()


    So far so good. Bu I want to be able to use the search part to show other dates, hence this code:

    OnSearchPartFilterCompute:
    Dim args as SQL::Arguments
    vDate = e.SearchDataSubmitted.UPDATED
    args.add("Date",vDate)
    e.rtc.filter_searchPart = "DATE(Updated) = :Date"
    e.rtc.parameters_searchPart = e.SearchDataSubmitted.Updated+"|||D|Date"

    Which works great all by itself. But shows no data if i use the first filter above.

    I need both; 1) show today's records, then 2) search on other dates. I can do either one, but not both.

    eh?

    P.S. I swear I've done this before but can't find an example.
    Peter
    AlphaBase Solutions, LLC

    [email protected]
    https://www.alphabasesolutions.com



    #2
    Re: Set grid filter OnInialize, then clear on search

    I think a solution could be not to set the filter in the mysql query but using javascript gridfilterset method. It sets a userfilter, so it wil be overruled when doing a new search.

    From the builder:

    //NOTE: The filter and order expression must be enclosed in single quotes. Therefore if your filter uses single quotes
    you must escape the single quote. e.g. 'customername = \'smith\''.
    You cannot use double quotes in the filter as it will cause a Javascript error.
    Therefore, the recommended approach is to always use a filter that has arguments, and pass in the argument values as the 3rd parameter to the method.
    (see examples below).
    //Filter the Grid to show orders above $1,000, ordered by orderTotal.
    {grid.Object}.gridFilterSet('ordertotal > 1000');
    //Sort the Grid by Lastname and within Lastname, by Firstname. (SQL Table)
    {grid.Object}.gridFilterSet('','Lastname, Firstname');
    //Sort the Grid by Lastname and within Lastname, by Firstname. (DBF Table)
    {grid.Object}.gridFilterSet('','Lastname+Frstname');
    If you use arguments in the filter (e.g. orderdate = :whatOrderdate), then you can specify parameter values with the
    'filterParameters' argument.
    The syntax for parameters is a '\n' (Javascript CRLF character) delimited string with value|||type|parameterName
    //Search for records where City is 'London'. Order result by 'Contactname'
    GRID1_GridObj.gridFilterSet('city=:whatCity' ,'Contactname','london|||c|whatCity\nuk|||c|whatcountry');
    //Search for records where City is 'London' and Country is 'UK'
    GRID1_GridObj.gridFilterSet('city=:whatCity and country = :whatCountry','','london|||c|whatCity\nuk|||c|whatcountry');
    Note: In the above example, the filter uses 2 arguments (:whatCity and :whatCountry). Therefore the 3rd parameter passed into the method
    defines these two arguments. Each argument is delimited with '\n' - the Javascript encoding of a CRLF character.
    Ger Kurvers
    Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.1 - 8722-5683(testing)
    Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

    Comment


      #3
      Re: Set grid filter OnInialize, then clear on search

      Thanks Ger. I tried that but no luck.
      Peter
      AlphaBase Solutions, LLC

      [email protected]
      https://www.alphabasesolutions.com


      Comment


        #4
        Re: Set grid filter OnInialize, then clear on search

        Strange... Maybe Alternative change the basefilter: http://wiki.alphasoftware.com/Grid+C...e+Filter+V10.5
        Ger Kurvers
        Alpha Anywhere / V4.6.1.9- Build 6488 (production) / V4.6.5.1 - 8722-5683(testing)
        Development: Mysql, windows 10 64 Applicationserver: standard on Windows server 2019

        Comment


          #5
          Re: Set grid filter OnInialize, then clear on search

          Got it to work - by cheating.

          Set this as the user filter in the tabbed_ui:

          DATE(Updated) = curdate()

          Then the regular search part worked using the code above in post#1.


          --
          BUT: if anyone knows the right way - i.e. w/o using the tabbed_ui as the starting filter please let me know.
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: Set grid filter OnInialize, then clear on search

            another workaround but probably still not the "right way" you're looking for, but you could put something like this in the onSearchRender:
            Code:
            var now = new Date();
            var month = now.getMonth();
            month = month + 1
            var day = now.getDate();
            var year = now.getYear();
            if(year < 2000) { year = year + 1900; };
            var datestr = month + '/' + day + '/' + year;
            
            {grid.Object}.setValue('S','DATEFIELD',datestr);
            
            {grid.Object}.submitSearchForm();

            Comment


              #7
              Re: Set grid filter OnInialize, then clear on search

              That's very nice, Chris. Works for me.

              I didn't know that the onSearchRender fires upon grid load. Cool.
              Last edited by Peter.Greulich; 12-16-2012, 12:49 PM.
              Peter
              AlphaBase Solutions, LLC

              [email protected]
              https://www.alphabasesolutions.com


              Comment


                #8
                Re: Set grid filter OnInialize, then clear on search

                You could also simplify Chris' javascript:

                var now = new Date();
                {grid.Object}.setValue('S','DATEFIELD', $u.d.toStr(now,'[mm]/[dd]/[yyyy]') );
                {grid.Object}.submitSearchForm();

                Comment


                  #9
                  Re: Set grid filter OnInialize, then clear on search

                  I use that approach in several places in our app, and it has its pros and cons, namely that the user can see what the original search criteria are, but the grid loads and then the search fires, so unless you hide the grid until a search is executed, the grid queries the data twice.

                  Thanks Andy for the shorthand. Most of my javascript is borrowed--I'm still learning things like you've got.

                  Comment


                    #10
                    Re: Set grid filter OnInialize, then clear on search

                    Yes. To avoid the double query, you can set the user filter from the button that opens the grid, and just display the filter value in the search box so that the user at lease knows the filter is active.

                    It also makes sense in search-oriented grids to keep the focus on the search box, so in several of the client-side js events (like onGridRenderComplete, afterSearchClear, etc.) you should put:
                    $('{Grid.ComponentName}.S.MYSEARCHFIELD').focus();

                    You might also wish to throw this in your onKeyPress event so that the enter key triggers the submit:
                    Code:
                    //capture the ENTER key from search part textbox
                    var keyCode = event.charCode || event.keyCode;
                    if (keyCode==13)	{grid.Object}.submitSearchForm();

                    Comment


                      #11
                      Re: Set grid filter OnInialize, then clear on search

                      Andy, at least with most Search Part control types, the enter key functions in that manner even without your code (though thanks for that insight). In fact, when Alpha offered the option of a search submit icon in v11 the functionality was lost until I asked them to replace it (and they did).

                      Comment


                        #12
                        Re: Set grid filter OnInialize, then clear on search

                        Oh, sorry, I had to do this in the past partly because there were instances where the ENTER key did not work because it was being trapped by parent components.
                        So you might keep it in your back pocket in case you need it :)

                        Comment


                          #13
                          Re: Set grid filter OnInialize, then clear on search

                          I have a similar need to default a grid to today's date and then be able to search by any other date, however, I am using a grid based on a stored procedure and am not able to choose a field to filter by on the TUI. Currently, I am using the onSearchRender event to set the date and fire the search, but I'd rather have the grid open with today's results rather than open and show a blank grid briefly while the search completes. I would like to set the default date in the argument setting but it complains about date() or now() not being a date value.

                          Not a critical issue, but it would be nice to use one step instead of two. Any suggestions?

                          Comment

                          Working...
                          X