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

Javascript To Find Out If Grid Is Dirty

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

    Javascript To Find Out If Grid Is Dirty

    If I want to execute some Xbasic only if the grid is not dirty, what is the Xbasic code for If Grid Is Dirty ?

    this does not work in Xbasic cuz the isdirty thing is javascript I think:
    If grid.isDirty = .t. then
    exit function
    end if

    I'm okay with using inline javascript to call the ajax callback function, but I can't seem to get the right isDirty line into the javascript either.
    If I need to do it with inline javascript, what is the code for just determining if the grid is dirty?

    I've searched the message board for isDirty and the Alphapedia but things I find are not directly about detecting if the grid is dirty. One was about if the detail view was dirty, but that doesn't help me. Thanks
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    #2
    Re: Xbasic for if grid is dirty

    I have tried this using in line javascript on the click of a button, but when I click the button when record is dirty,
    nothing happens.

    Code:
    if({Grid.Object}.isDirty == true)
    {
    alert('Please Save your information first.');
    }
    else
    {
    {grid.Object}.ajaxCallback('G','{grid.rownumber}',' 'AppendPaymentRecords','','_getData=true');
    }
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    Comment


      #3
      Re: Xbasic for if grid is dirty

      {grid.Object}.ajaxCallback('G','{grid.rownumber}',' 'AppendPaymentRecords','','_getData=true');

      I dont think your grid.rownumber should be surrounded in quotes - this could be the reason your callback isnt firing.


      "Nothing happens" - is never true in javascript.
      Something happened.

      In this case - I think it was an error. Use firefox's Tools>Error Console to see if any underlying javascript errors are occurring.
      I think ajaxCallback() requires the second arg to be numeric - this may be the cause of your error (not sure though).

      Are you sure the isDirty property exists? Alpha's javascript documentation sucks - goodluck finding the right variable :(
      Scott Moniz - Computer Programmer/Analyst
      REA Inc.
      http://reainc.net
      (416)-533-3777
      [email protected]

      REA INC offers consulting services, programming services, systems design, database design, third party payment gateway integration (CHASE, PAYPAL, AUTHORIZE.NET) and developer support.
      If you need custom code, or 1-to-1 mentoring in any facet of your database/web application design,
      contact us to discuss options.

      Comment


        #4
        Re: Xbasic for if grid is dirty

        In your first example you are mixing up JS w. xbasic - a no-no.

        This might be the JS syntax to call an xbasic function if the grid row is dirty, using the OnRowStateChange JS system event:

        Code:
        if (e.isDirty == true)
        {
        alert('Grid is dirty');
        }
        or

        Code:
        //call a user-defined xbasic function if the grid row is dirty
        if (e.isDirty == true)
        {
        {grid.Object}.ajaxCallback('G','{Grid.RowNumber}:all','SomeFunction','','');
        }
        Peter
        AlphaBase Solutions, LLC

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


        Comment


          #5
          Re: Xbasic for if grid is dirty

          Hi Scott - I have used that line for ajax callback many times in In Line javascript, and, yes, you do have to have the quotes... which I learned after much trial and error without them. I think Selwyn even ended up giving me some explanation about why they are necessary there. Also, I was making grid dirty to test, so the callback would not have happened, so it wouldn't have been about that. The problem, I'm sure, was with the isDirty part.

          So, now, Peter, I am going to go try your suggestion and will report back. Thank you!
          Carol King
          Developer of Custom Homebuilders' Solutions (CHS)
          http://www.CHSBuilderSoftware.com

          Comment


            #6
            Re: Xbasic for if grid is dirty

            Yep, Peter, I understand about the difference between Javascript and Xbasic (although it took awhile at first). I should have said that I gave up on trying to find out if the grid was dirty with Javascript and wondered if there was a way to check if the grid was dirty in Xbasic.

            ANYWAY, the javascript you posted above for e.isDirty is not working. I put the code below in the onClick event of a button using In Line Javascript.
            Then I published it, opened it on Local Host, made the grid dirty, and when I click the button, it does the Ajax callback (you're right, Scott, something does happen). So, for some reason, it is not detecting that the gird is dirty. I have also tried to put something like e.isDirty = False in the Enable property of the button, so that the button would only be enabled if the grid was not dirty, but have failed there, too.

            Code:
            if (e.isDirty == true)
            {
            alert('Please Save your information first.');
            }
            else
            {
            {grid.Object}.ajaxCallback('G','{grid.rownumber}',' 'AppendPaymentRecords','','_getData=true');
            }
            I wish I could find somewhere in the Alpha help how to simply detect if a grid is dirty. Seems like this would be a common requirement for developers.
            Carol King
            Developer of Custom Homebuilders' Solutions (CHS)
            http://www.CHSBuilderSoftware.com

            Comment


              #7
              Re: Xbasic for if grid is dirty

              Originally posted by kingcarol View Post
              ANYWAY, the javascript you posted above for e.isDirty is not working.
              It works for me - in the OnRowStateChange JS system event.
              Peter
              AlphaBase Solutions, LLC

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


              Comment


                #8
                Re: Xbasic for if grid is dirty

                Yep, I've used e.isDirty in the OnRowStateChange JS event before, but I am trying to very simply find out if the grid is dirty when I click a button. I know I can use a variable to react to the OnRowStateChange event, and use the AfterGridSubmit to change the variable, etc., and then read that variable upon clicking the button. However, when I've done that before, I've ended up having to take care of that variable in several other events, and I was hoping there just a simple way to detect if grid was dirty when a button was clicked, without dealing with the OnRowStateChange and resulting requirement of a variable that's changing.
                Carol King
                Developer of Custom Homebuilders' Solutions (CHS)
                http://www.CHSBuilderSoftware.com

                Comment


                  #9
                  Re: Xbasic for if grid is dirty

                  Have you tried the {grid.Object}._getGridVariables(grid,detailView); method (Action Javascript > Inline Javascript > Insert Grid Method)?

                  Comment


                    #10
                    Re: Xbasic for if grid is dirty

                    xbasic is server side code. it has no knowledge of the state of the grid unless that information is passed back to it in the ajax callback.

                    on the client side, you can can simply read a variable in the Grid Object. for example, put this code in a button on your grid:

                    alert({Grid.object}._isDirty);

                    Comment


                      #11
                      Re: Xbasic for if grid is dirty

                      OK, I put the alert suggested by Selwyn on a button and I get the true and false as expected when dirty or not dirty. However, when I put the following code on a button, nothing happens when I click the button. Here's a very short video: http://screencast.com/t/CSpBs9sqBK

                      Code:
                      if ({Grid.object}._isDirty == true)
                      {
                      alert('Please Save your information first.');
                      }
                      else
                      {
                      {grid.Object}.ajaxCallback('G','{grid.rownumber}',' 'AppendPaymentRecords','','_getData=true');
                      }
                      Carol King
                      Developer of Custom Homebuilders' Solutions (CHS)
                      http://www.CHSBuilderSoftware.com

                      Comment


                        #12
                        Re: Xbasic for if grid is dirty

                        I just tested this code on a button and it works.
                        Don't know why your test case is not working.



                        Code:
                        if({Grid.object}._isDirty == true) {
                        	alert('grid is dirty');
                        } else {
                        
                        	alert('grid is not dirty - ok to submit');
                                //you can put your ajax callback here
                        
                        };

                        Comment


                          #13
                          Re: Xbasic for if grid is dirty

                          Carol, you have an extra single quote in the ajaxCallback. That is probably throwing an exception.
                          Stephen Pilon
                          Associate Librarian
                          Christendom College

                          Comment


                            #14
                            Re: Xbasic for if grid is dirty

                            Thank you so much, Stephen. I spotted that this morning. ALSO, Scott, my apologies... you were right. The single quotes around the grid.rownumber did need to be removed. I was getting myself confused with the single quotes that are needed around that if you are making an ajax callback in a Client Side event that occurs AFTER another ajax callback. A few months ago, I kept trying to put that callback code in the AfterAjaxCallbackComplete client side event and did not have single quotes around the grid.rownumber and found out I needed them. At that time, then, Selwyn explained it to me like this:

                            the '{grid.rowNumber}' placeholder is meaningless in the context of an afterAjaxComplete event.

                            the {grid.rowNumber} placeholder is only meaningful for code that is inserted into individual rows of a grid. it then gets replaced at render time with the actual row number.

                            so, in an afterAjaxCallbackComplete, the {grid.rownumber} placeholder does NOT get replaced (what value would it be replaced with? ).
                            and so the the code that gets rendered still has {grid.rowNumber} in it.

                            if you don't put it in quotes, then javascript will try to interpret this as a real object - which it is not - and so you get an error.

                            but if you put it in quotes, then it is just a literal string and hence no error..
                            I have gotten so used to using that code in some After.... client side events that I got myself confused...

                            ANYWAY... this code is now working:

                            Code:
                            if({Grid.object}._isDirty == true) {
                            	alert('Please Submit Your Information first.');
                            } else {
                            	{grid.Object}.ajaxCallback('G',{grid.rownumber},'AppendPaymentRecords','','_getData=true');
                            };
                            I noticed Selwyn's example had a semi colon after the last curly bracket, so I put one in also. I'm not sure if that's necessary.

                            Thanks, Selwyn, and everyone who assisted with this. I'm sure I'll be using the ._isDirty feature quite a bit. I hope it helps someone else.
                            Last edited by kingcarol; 07-12-2011, 08:46 AM.
                            Carol King
                            Developer of Custom Homebuilders' Solutions (CHS)
                            http://www.CHSBuilderSoftware.com

                            Comment


                              #15
                              Re: Xbasic for if grid is dirty

                              I think it would be good if I knew how to change the title of this thread to: Javascript To Find Out If Grid Is Dirty
                              Carol King
                              Developer of Custom Homebuilders' Solutions (CHS)
                              http://www.CHSBuilderSoftware.com

                              Comment

                              Working...
                              X