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

SOLVED: Handling State variables in a Grid when they have not been initialized

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

    SOLVED: Handling State variables in a Grid when they have not been initialized

    FYI: State Variables can be a convenient way of passing data around, but sometime ago I noticed a problem in a particular Grid. The State variables were not being initialized early enough in the component on the client-side. Alpha may have fixed the issue, as I did report it, but incase it was not or could not be fixed, or if you encounter something similar with the State variables not being initialized by the time you need them, I thought I'd offer my solution:

    In my situation the event (or events) where I needed to access Grid State variables were being invoked by the A5 library twice before the Grid was actually displayed to the user. The first time around the State variables were not initialized. The second time A5 fired the event the State variables were initialized. My JavaScript functions that need access to the State Variables include the following at the top of them:

    Code:
    if( ("stateInfo" in {Grid.object}) && ("myVariable_or_Object" in {Grid.object}.stateInfo) ) {
        // do something
    }
    I was lucky in this solution as the A5 library was firing the event a second time, for me, with the State Variable, initialized. If the library was not doing that then I would have coded the function with a setTimeout function to try calling it again.

    #2
    Re: SOLVED: Handling State variables in a Grid when they have not been initialized

    Rich, are you still using this technique or have you updated it?

    Comment


      #3
      Re: SOLVED: Handling State variables in a Grid when they have not been initialized

      I am still using the technique.

      Last week I looked at what it would take to fix the AA JavaScript Library and I do not expect it will ever be fixed. There are over 900 lines of client-side code being executed when a Grid is initialized and moving the code that initializes the stateInfo object for a Grid on the client-side up to where it should be could break something.

      Another, Grid that I was working on last week had similar problem with stateInfo not being initialized. I needed it to be available during the Grid initialization process when the Grid's "onRowRender" event fires for each row. So, what I did was to wait until "onGridInitializeComplete" and then call my own function for finalizing the Grid before it becomes visible (although, in debug mode it will be visible).

      In that client-side embed, I attach my local functions to the Grid object. I think a simple example would go like this:
      Code:
      {Grid.object}._functions.finalGridSetup = function(rows) {
         var gr = {Grid.object};
         try {
           for( nn=1; nn <= rows; nn++ ) {
               gr._functions.applyMyRowStyle(nn, true);
           }
         }
         catch(err) {
             alert('Some error message or maybe just ignore the issue.');
         }
      };
      {Grid.object._functions.applyMyRowStyle = function( row, isFirstTime ) {
          // Tweak various class names or inline styles for the row.
      };
      // Delay a bit and then run our Grid Setup function
      setTimeout( {Grid.object}._functions.finalGridSetup(this.actualRowsOnPage), 250 );
      My Grid has an updateable view. When a detail record is saved, I want the Grid to be redrawn or styled, so I put something like this in the "afterRowPopulate" client-side event:

      Code:
      // Called after Detail View has updated a row.
      setTimeout({Grid.object}._functions.applyMyRowStyle(e.rowNumber,false),100);
      The above is not exactly how I am doing things, but it gives the general idea.
      One of the major things I am doing differently is that I use only one variable inside of the stateInfo object. I place a JSON string in it and expand it into a JSON object inside of the Grid's '_functions' object. In my 'finalGridSetup' function I start with this (inside of that try block):

      Code:
      this.myVars = JSON.parse( gr.stateInfo.JSONVarStr );
      That allows all of my local functions that I have attached inside the Grid's "_functions" object to access my variables by Scope, like this:

      Code:
      var rateScale = this.myVars.rateScale;

      Comment


        #4
        Re: SOLVED: Handling State variables in a Grid when they have not been initialized

        It seems to me that the Grid State Variable feature is broken. Here's another link that discusses this. The UX State Variables work properly.

        https://forum.alphasoftware.com/show...nsient-message

        Comment


          #5
          Re: SOLVED: Handling State variables in a Grid when they have not been initialized

          Thanks, Rich. I'm working on a technique with the grid components so that I won't need to use session variables.
          1. Set Args
          2. Get the Args value in the Grid Execute embed.
          3. Use State Variables to load various columns on the Insert and Update embeds.

          Comment


            #6
            Re: SOLVED: Handling State variables in a Grid when they have not been initialized

            Originally posted by Davidk View Post
            It seems to me that the Grid State Variable feature is broken. Here's another link that discusses this. The UX State Variables work properly.

            https://forum.alphasoftware.com/show...nsient-message
            Yeah, broken or perhaps just not implemented as one would expect. Another thing that bothers me about state variables is their overhead: 1) once they make it down to the Grid on the client side, they are always sent back to the server and if you don't need them then that is a little bit of waste, 2) it could be that there is a bunch of extra work the server and client has to do when there are a lot of state variables that have to be packaged up for transit down to the client and then packaged up for the server.

            If Alpha has to make a choice between "fixing" the stateInfo object for a Grid or doing something else for a Grid, I would prefer the ability to return JavaScript in the server-side "OnGridInitialize". I would want some flexibility of specifying where to insert the JavaScript. With over 900 lines of JS being returning in response to opening a Grid, there are plenty of places where one might want to insert their own JavaScript. I would like to return JavaScript after the point where the "{Grid.object}._functions" object is initialized. At that point I would run JavaScript to initialize member variables inside of that object. This way, the functions that I attach to that object would have access to the member variables through JavaScript Scope (If that is the correct terminology, the member variables can be accessed via 'this.').

            Comment


              #7
              Re: SOLVED: Handling State variables in a Grid when they have not been initialized

              Originally posted by RichCPT View Post
              Yeah, broken or perhaps just not implemented as one would expect. Another thing that bothers me about state variables is their overhead: 1) once they make it down to the Grid on the client side, they are always sent back to the server and if you don't need them then that is a little bit of waste, 2) it could be that there is a bunch of extra work the server and client has to do when there are a lot of state variables that have to be packaged up for transit down to the client and then packaged up for the server.
              This is the hole point. How else would they work?

              Exactly same situation is in Asp.Net Web Forms. In Asp.Net you can turn them off if you do not want to use them. In Alpha you have also the choice to use or not use them.

              So this is a question of benefits vs performance.

              Ken

              Comment


                #8
                Re: SOLVED: Handling State variables in a Grid when they have not been initialized

                Originally posted by kkfin View Post
                This is the hole point. How else would they work? Ken
                Right, with a name like "state variable" one would expect them to persist between client and server. My suggestion of being able to send JavaScript back during the server-side "OnGridInitialize" event and to specify when the JS should be run, would let me create variables that one might refer to as Grid Object Variables. I think we are just looking for a way to have client-side variables in a Grid that are not implemented as hidden controls or as stateInfo object variables. "Grid Object Variables" are essentially what I'm creating now, but since the stateInfo object is not initialized until the very last thing, I have to delay creation of my variables until after that point (which is after the grid rows have been rendered) and then loop through all the rows in the grid applying my style tweaks.

                Comment

                Working...
                X