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

Checkbox input in grid toolbar - when checked, change filter

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

    Checkbox input in grid toolbar - when checked, change filter

    I successfully positioned an input checkbox in a grid toolbar (See attached), and now would like to have it change the grid filter when check/unchecked.

    Here's the html to add the checkbox:
    Code:
    <input type="CHECKBOX" id="IncludeInactive" name="IncludeInactive" value=".f.">Include Inactive
    The concept is; there is an 'IsActive' field (MySQL tinyint) in the table the grid is based on, and the base filter is 'IsActive = 1'. So when the grid is first opened, only 'active' records are displayed. What I want is when user clicks on the above mentioned checkbox, the base filter would change to include all records, and vise-versa.

    Any ideas how to accomplish this?
    Attached Files
    - Dan Hooley
    - Custom Desktop or Web database development -

    #2
    Re: Checkbox input in grid toolbar - when checked, change filter

    Because we've been given such great access to the features of A5 this can be done with just a bit of js. I'm not sure about the base filter being set - not sure if you can change that - however you could change the grid so that all records are in the base filter, and then filter the grid when it's rendered. However, this is how you could filter the grid based on your checkbox.

    First, take out the value setting of your checkbox - you don't want to control it at this level... we'll do that elsewhere.
    Next, alter the checkbox html a bit adding an onclick js event: onclick="chkSearch();"
    Next, in the Grid Properties, Javascript - Other, under Javascript Function Declarations, add this function:

    Code:
    function chkSearch()
    {
    if ($('IncludeInactive').checked == false)
    	{
    	varflagInclude = false;
    	{grid.Object}.gridFilterSet('InActive = 1');
    	}
    else
    	{
    	varflagInclude = true;
    	{grid.Object}.gridFilterSet('');
    	}
    }
    In the Javascript - System Events, onGridRender

    Code:
    if (varflagInclude)
    	{
    	if (varflagInclude == true)
    		{
    		$('IncludeInactive').checked = true;
    		}
    	else
    		{
    		$('IncludeInactive').checked = false;
    		}
    	}
    and in the Javascript - System Events, onObjectInitialize

    Code:
    varflagInclude = '';
    So, the grid opens (and let's say gets filtered on InActive=1). You check your checkbox and chkSearch get fired, checks the value of your checkbox and resets the filter. The grid gets redisplayed and checks the value of our variable varflagInclude to see if we need to turn the checkbox on or off - in order to keep it in the same state as we last checked it.

    Comment


      #3
      Re: Checkbox input in grid toolbar - when checked, change filter

      Thanks, David! I thought that might be the case, just don't know enough js.

      I got everything set, but am having a little problem with the filter. When I check the checkbox, nothing changes and when I uncheck it, the grid disappears and I get this error:
      Could not get count of records in query.

      Maybe I mislead you a little as my grid is actually based on a select statement with a where clause (WHERE Items.IsActive = 1), not a base filter. However, I took the where clause out and it still gives me the error. The 'IsActive' field is in the grid as a hidden field. Not sure what the gridFilterSet function is doing, so not sure how the fields affect it.

      Thanks, Dan
      - Dan Hooley
      - Custom Desktop or Web database development -

      Comment


        #4
        Re: Checkbox input in grid toolbar - when checked, change filter

        There are so many ways to get this stuff done... and it comes down to how you want your system to behave.

        Instead of basing your Grid on a subset of data, include everything and then, in the Javascript - System Events - onGridInitalizeComplete (which only fires once) set the filter

        {grid.Object}.gridFilterSet('IsActive = 1');

        So the grid displays, gets filtered, but has all the records available to you and your checkbox

        Although not sure why you'd be getting a Count error - no counting going on that I can see... might be something else you're doing.

        Because you're going to initially filter the grid, then change the js function a bit. The grid is filtered to begin with, you check the checkbox making it True and so then unfilter the grid. If you uncheck the checkbox, then filter the grid again.

        Code:
        function chkSearch()
        {
        if ($('IncludeInactive').checked == true)
        	{
        	varflagInclude = true;
        	{grid.Object}.gridFilterSet('');
        	}
        else
        	{
        	varflagInclude = false;
        	{grid.Object}.gridFilterSet('ProductId = 100001');
        	}
        }

        Comment


          #5
          Re: Checkbox input in grid toolbar - when checked, change filter

          I switched to a view that does everything my select statement was doing and got it to work. Also, because this grid has a tree navigator, I used:
          Code:
          {grid.Object}.grid[U]Base[/U]FilterSet('IsActive = 1');
          so the tree navigator does not override the filter.

          The only enhancement I might look for is if it could keep the tree navigator selection. The way it is, if you make a selection in the tree navigator and then check or uncheck this box, it 'overrides' the tree navigator. Not a big deal, but would be a nice improvement.

          Also, would like the checkbox to float to the right of the grid toolbar.

          Thanks again, you've been most helpful.
          Dan
          - Dan Hooley
          - Custom Desktop or Web database development -

          Comment


            #6
            Re: Checkbox input in grid toolbar - when checked, change filter

            You can right align by putting in a bit of extra stuff... here's my Grid Toolbar with extra Table, TR and TD codes. Not sure if you need all that stuff but it works and my html is embarrassing.

            Code:
            <tr>
            	<td colspan="{grid.colspan}" class="[class.gridPartToolbar]" nowrap="nowrap" >
            
            		<table cellspacing="0" border="0" cellpadding="0" style="width:100%;">
            			<tr>
            				<td nowrap="nowrap" align="right">
            				<input type="CHECKBOX" id="IncludeInactive" onclick="chkSearch();" name="IncludeInactive" >Include Inactive</input>
            				&nbsp;
            				</td>
            			</tr>
            		</table>
            
            		<table cellspacing="0" border="0" cellpadding="0" style="width:100%;">
            			<tr>
            				<td nowrap="nowrap" align="{grid.RecordNavigatorAlignment}">
            					{grid.GridViewAddNewRecordHyperlink} {grid.RecordNavigatorButtons} {grid.RecordsPerPage}&nbsp;&nbsp;&nbsp;{grid.toggleQBERowHyperlink}
            					&nbsp;&nbsp;{grid.ActionButtonHTMLTemplate}
            					&nbsp;{grid.HelpWindowButton}
            				</td>
            				<td nowrap="nowrap" align="right">
            					{grid.grid_part.submitbuttons}
            					{ActionButton:SUBMIT}
            				</td>
            			</tr>
            		</table>
            	</td>
            </tr>

            Comment


              #7
              Re: Checkbox input in grid toolbar - when checked, change filter

              This got me what I want:

              Code:
              <tr>
              	<td colspan="{grid.colspan}" class="[class.gridPartToolbar]" nowrap="nowrap" >
              		<table cellspacing="0" border="0" cellpadding="0" style="width:100%;">
              			<tr>
              				<td nowrap="nowrap" align="{grid.RecordNavigatorAlignment}">
              					{grid.DetailViewAddNewRecordHyperlink}
              					{grid.RecordsPerPage}
              				</td>
              				<td nowrap="nowrap" align="right">
              					<input type="CHECKBOX" id="IncludeInactive" name="IncludeInactive" onclick="chkSearch();" align="right">Include Inactive</input>
              				</td>
              			</tr>
              		</table>
              	</td>
              </tr>
              Notice it's all within the same table and row so everything shows up nicely in the grid toolbar on the same row.
              - Dan Hooley
              - Custom Desktop or Web database development -

              Comment


                #8
                Re: Checkbox input in grid toolbar - when checked, change filter

                Good... I figured you'd get there... looks good.

                Comment


                  #9
                  Re: Checkbox input in grid toolbar - when checked, change filter

                  David,

                  After reading your posts I have decided to set the initial filters on some of my grids using the {grid.Object}.gridFilterSet() method. It seems to work a little faster than setting the values of the fields in the search part and then using {grid.Object}.submitSearchForm() method in the OnSearchRender event.

                  The problem I have is that on some machines outside of the LAN the grid displays all of the records for a short time before the filter is set in the OnGridInitializeComplete event. I am using a messagebox to lock the screen until the filter is set but do to the asynchronous, multi-threaded operation of javascript the msgBox.hide() runs before the filter is complete and the grid refreshes. Any ideas of how or where to put the msgBox.hide() to keep it up until the computing is complete?
                  Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                  Comment


                    #10
                    Re: Checkbox input in grid toolbar - when checked, change filter

                    See if this might work... I can see it here but it's moving kinda fast so I can't tell if it's working.

                    Put your filter into an ajax callback.

                    In the onGridinitializeComplete event:

                    Code:
                    //place this Javascript in your code, and then reference the rowNum variable.
                    var rowNum = {Grid.Object}._selectedRow;
                    {grid.Object}.ajaxCallback('G',rowNum,'setGridFilter');
                    The setGridFilter callback will be like this:

                    Code:
                    function setGridFilter as c (e as p)
                    
                    setGridFilter = "A5.msgBox.show('Filtering records...','Please hold on a sec...','none',function() {});{grid.Object}.gridFilterSet('ProdId = 100001');"
                    	
                    end function
                    And... in the Javascript Event - afterAjaxCallbackComplete - put this:

                    Code:
                    if (e.ajaxEvent == 'SetGridFilter')
                    	{
                    	A5.msgBox.hide();
                    	}
                    I see this as forcing an order to things... kind of... not sure if it will work though.

                    Comment


                      #11
                      Re: Checkbox input in grid toolbar - when checked, change filter

                      Thank you David,

                      After experimenting with different scenarios I have decided to use the following procedure which is almost perfect. Thank you for pointing me in the right direction.

                      In the OnSearchRender Event.
                      Code:
                      A5.msgBox.show('Loading...','<div style=\'padding: 20px;\'>Please wait while Grid Loads.</div>','none',function() {});
                      {grid.object}.setValue('S','INVOICED','0');
                      {grid.object}.setValue('S','CLOSED','0');
                      {grid.object}.setValue('S','COMPLETE','0');
                      {grid.Object}.gridFilterSet('INVOICED = 0 and CLOSED = 0 and COMPLETE = 0');
                      In the AfterAjaxCallback Complete
                      Code:
                      	try
                      	{
                      		A5.msgBox.hide();
                      	}
                      		catch(e){
                      	}
                      Last edited by frankbicknell; 08-25-2011, 07:49 AM.
                      Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                      Comment


                        #12
                        Re: Checkbox input in grid toolbar - when checked, change filter

                        Nice... I like that.

                        Comment


                          #13
                          Re: Checkbox input in grid toolbar - when checked, change filter

                          If I can resurrect this with one curve:

                          I have a grid that gets called from several tabbed UI buttons that pass in different filters. I was able to get the filter value from this post and store it in a js var and add/subtract it to the 'IsActive' filter setting for the checkbox, and all works great as long as only 1 instance of the grid is open. But if I open more then 1, it doesn't work and seems to mix filter values. Wondering if the js vars are living in the same name space on all instances and so it doesn't know the difference between the different instances?? Any ideas how this can be remedied?

                          Thanks,
                          - Dan Hooley
                          - Custom Desktop or Web database development -

                          Comment


                            #14
                            Re: Checkbox input in grid toolbar - when checked, change filter

                            Hi Dan,
                            Your JS variables are likely being defined (by default) as global in scope.
                            For TabbedUI, to give each TAB window a separate scope, I normally define a single global object, then have sub-objects for each TAB, then assign properties to these.

                            For example:

                            Code:
                            //global Object container for entire app.
                            if (typeof AG_JOBTRACK == 'undefined') window["AG_JOBTRACK"] = {};
                            
                            //check for TabbedUI interface
                            if (typeof tbiObj != 'undefined') {
                            	AG_JOBTRACK["LastTabName"] = tbiObj._tbObj._panes[tbiObj._tbObj._curTabIndx].name;
                            } else {
                            	AG_JOBTRACK["LastTabName"] = "test";
                            }
                            
                            AG_JOBTRACK[AG_JOBTRACK.LastTabName] = {};
                            AG_JOBTRACK[AG_JOBTRACK.LastTabName].IsSet = true; //check this before using data
                            AG_JOBTRACK[AG_JOBTRACK.LastTabName].GridRow = {grid.object}._selectedRow;
                            AG_JOBTRACK[AG_JOBTRACK.LastTabName].JobID = {grid.object}.getValue('G','JOBID',{Grid.object}._selectedRow);
                            AG_JOBTRACK[AG_JOBTRACK.LastTabName].JobCode = {grid.object}.getValue('G','BQ_PROJECTCODE',{Grid.object}._selectedRow);
                            It is a bit more hassle than defining a bunch of globals, but it works for me because I can easily separate the variable scopes. The "test" sub-object allows the grid to work outside of a tabbedUI environment.

                            Andy.

                            Comment

                            Working...
                            X