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

Display Record Count in a UX

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

    Display Record Count in a UX

    I have a UX based on a MySql table.

    I want to display text "Record 3. Found 15 of 98000"
    3 is the 3rd record in the result set, currently being displayed.
    15 is the number of records in the current result set.
    98000 is the total number of rows in the table.

    This is similar to the message being displayed in the slider that is available in the Load_Primary_keys_for_Parent_Table action in the onDialogInitialize event. It uses placeholders {recordNumber} and {recordcount}.

    But I want to do this independently of a slider or list control.

    I believe the data I am after is in the e object.

    Can anyone tell me the best way to do this?

    #2
    Re: Display Record Count in a UX

    Anyone?

    Comment


      #3
      Re: Display Record Count in a UX

      Here is a related question....

      In the Action Javascript "Get Primary Key List" builder, there is an "After Search" client-side event. It says it takes e as an argument. e.recordsInQuery contains the number of records in the query.

      How do I pass e.recordsInQuery into a Javascript function?

      Comment


        #4
        Re: Display Record Count in a UX

        I think this is what you're looking for...

        http://www.youtube.com/watch?v=L2EQGJIqkrE

        Here are all the bits and pieces...

        Code:
        function jsAfterSearch(e){
        
        	if (e.recordsInQuery>0){
        		{dialog.Object}._recInfo.queryRecCount = e.recordsInQuery
        	} else {
        		{dialog.Object}._recInfo.queryRecCount = {dialog.Object}._recInfo.totalRecCount;
        	}
        
        	updateRecordInfo();
        	
        }
        Code:
        function updateRecordInfo(){
        
        	$("recInfo").innerHTML = "Record " + {dialog.Object}._currentRecordNumber + ". Found " + {dialog.Object}._recInfo.queryRecCount + " of " + {dialog.Object}._recInfo.totalRecCount;		
        
        }
        Client-side Event : afterRecordNaviagate

        Code:
        updateRecordInfo();
        Client-side Event : onRenderComplete

        Code:
        {dialog.Object}._recInfo = {};
        {dialog.Object}._recInfo.totalRecCount = {dialog.object}._primaryKeyList.length;
        {dialog.Object}._recInfo.queryRecCount = {dialog.Object}._recInfo.totalRecCount
        updateRecordInfo();

        Comment


          #5
          Re: Display Record Count in a UX

          Excellent. Can't thank you enough.

          One more question comes up in my application. What about when the number of records changes?

          This will get the number of records in the mySql table named "loads", and display it in a div:

          function totalRecordCountInLoadsTable as c (e as p)
          dim cn as sql::Connection
          dim rs as sql::ResultSet
          sql = <<%a%
          SELECT COUNT(*)
          FROM loads
          %a%
          cn.open("::Name::FreightzoneMySql")
          cn.execute(sql)
          rs = cn.ResultSet
          count = rs.data(1)
          cn.close()

          dim countAllRecords as c
          countAllRecords = "$('totalRecords').innerHTML='of ' + '" + js_escape(count) +"';"

          totalRecordCountInLoadsTable = countAllRecords

          END FUNCTION

          It works just fine. But only needs to fire on INSERT and DELETE.

          In afterDialogValidate, Save Submitted Date To Tables builder, there are server side events: AfterRecordInsertFunction and AfterRecordDeleteFunction. Using totalRecordCountInLoadsTable does not seem to do anything.

          How can I fire this only on INSERT or DELETE?

          Or is there a better way?

          Comment


            #6
            Re: Display Record Count in a UX

            I'm not sure about the server-side events in the afterDialogValidate event. I believe they'll only fire if afterDialogValidate runs... which, of course, makes sense. On an Insert... it runs because a Submit occurs. But on a delete the afterRecordDelete doesn't run because the afterDialogValidate doesn't run. Have to check on this.

            So... let's do this another way.

            In the Client-side afterDeleteParentRecord event...

            Code:
            {dialog.Object}._recInfo.totalRecCount = --{dialog.Object}._recInfo.totalRecCount
            {dialog.Object}._recInfo.queryRecCount = --{dialog.Object}._recInfo.queryRecCount;
            updateRecordInfo();
            Here we are decrementing the total record count and query record count when a record has been deleted.

            In the Server-side afterDialogValidate event... AFTER the ExecuteServerSideAction...

            Code:
            e.javascript = e.javascript + "afterInsRecord('" + e.rtc.primaryTableEditMode + "');"
            Here... AFTER your your normal ExecuteServerSideAction, we append our own javascript function... and we pass into that function e.rtc.primaryTableEditMode which will have a value of Enter or Update.

            Code:
            function afterInsRecord(editMode){
            
            	if (editMode=='Enter'){
            		{dialog.Object}._recInfo.totalRecCount = ++{dialog.Object}._recInfo.totalRecCount;
            		{dialog.Object}._recInfo.queryRecCount = ++{dialog.Object}._recInfo.queryRecCount;		
            	        updateRecordInfo();
            	}
            	
            	if ({dialog.Object}._recInfo.currSearchParam){
            		{dialog.Object}.setValue('txtSearchFor',{dialog.Object}._recInfo.currSearchParam);
            		{dialog.object}.buttonClick('BTNSEARCH');
            	}
            
            }
            When afterDialogValidate runs... for an update or insert... then this function will be called. We know if it's Enter or Update. If it's enter then we're adding a new record and so increment our counts. If it's an Update then we don't want to increment.

            Here's another wrinkle. Let's say you did a search. You've got 23 of 88 records... and you add a new record. Now... all this depends on how you want your app to behave... but... since you've got an active search you may want that "process" to continue. The javascript function afterInsRecord checks to see if there is a current search going on, just by checking the search textbox. If there is, then we save the current search param, add the new record and re-execute the search. Not all that is going on in this function... but that's the general idea.

            In the Search textbox, client-side onBlur event I put this... which saves the search value.

            Code:
            var currSearch = {dialog.Object}.getValue('txtSearchFor');
            {dialog.Object}._recInfo.currSearchParam = currSearch;
            The afterInsRecord javascript function checks for a search, puts it back in place (because a New Record action clears it) and executes the search again.

            It's getting kinda complicated so I'm guessing there's an easier way to do all this. However... this is a great exercise in seeing how all the calls and tools fit together. It's very cool.

            Comment


              #7
              Re: Display Record Count in a UX

              Originally posted by Davidk View Post
              I'm not sure about the server-side events in the afterDialogValidate event. I believe they'll only fire if afterDialogValidate runs... which, of course, makes sense. On an Insert... it runs because a Submit occurs. But on a delete the afterRecordDelete doesn't run because the afterDialogValidate doesn't run. Have to check on this.
              It would be interesting to know what these events are for.

              As for updating the total records count, I agree that the solution you propose is kinda complicated. I believe for my application, I would probably go the easier route of making the user click a button to show the total record count. This is not an ideal solution, so I will see how your solution fits.

              Of course, if a record is added or deleted, and it affects the results of the current search, the records in query number should also be updated. It looks like your solution addresses this.

              I mentioned that I would like to do all of this independently of a list or slider. But it would be interesting to know exactly how the slider message gets updated.

              As an additional wrinkle, I have some ajax callbacks that I use in this UX. So the Action Javascript "Get Primary Key List" is not being used. So I have modified your original posed solution by using two spans:
              <span id="recInfo"</span>
              <span id="recordsInQuery"</span>

              With a separate function to update one or both as needed:
              function updateRecordInfoOnNavigate(){

              $("recInfo").innerHTML = "Record " + {dialog.Object}._currentRecordNumber;

              }

              function updateRecordInfoOnSearch(){

              $("recInfo").innerHTML = "Record " + {dialog.Object}._currentRecordNumber;
              $("recordsInQuery").innerHTML = "Found " + {dialog.Object}._recInfo.queryRecCount;

              }

              In a callback, I use this to get the record count in the query:
              SELECT
              COUNT(1),

              and update the recordsINQuery with this:
              "$('recordsInQuery').innerHTML='Found ' + '" + js_escape(queryCount) +"';"

              This all seems to work just fine.
              Last edited by Pizzadude; 09-07-2014, 03:59 PM.

              Comment

              Working...
              X