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

How to disable a grid field if callback conditions are true

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

    How to disable a grid field if callback conditions are true

    I have a parent table with a field PROD_CODE that relates to child tables. One of the child tables is a table that has data only when current payroll is being processed, and I don't want a user to be able to edit the value in the parent PROD_CODE table if it's found in that child table. Otherwise, it's ok to edit it. I already know how to check to see if the PROD_CODE is being used in that child table, and how to do the if staetment in my Ajax callback function. I am just trying to find out how to disable the parent field PROD_CODE so it can't be edited if it is found in that child table. I think I need to use the e._set object, but can't find a list of all the properties that can be set by using it. Is there one that can enable or disable a field? something like:

    e._set.PROD_CODE.enable = .f.

    Are the only properties that can be set with the e._set object the ones shown in the alphapedia article below (like setting values or styles), or is there a full list of others somewhere?
    http://wiki.alphasoftware.com/User+D...ghlight=e._set.


    ALSO, I haven't determined if my Ajax Callback should be called from OnFocus client side event for the field, or if I should use a focus event for the row. Once I find out how to get a field to disable, then I'll test it in the various events. Any suggestions for which event I should try? I'm thinking trying to disable a field while it has focus might be wierd. Don't know yet. In Access, I use an OnCurrent event for the row to do these types of things.
    Last edited by kingcarol; 08-24-2010, 09:10 AM.
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    #2
    Re: How to disable a grid field if callback conditions are true

    Well, I may not need something like e._set.PROD_CODE.enable = .f. (made up by me)...
    because my function for the field's OnFocus event calls a javascript alert box if the function finds that field should not be edited, and the user has to click OK in the alert box. It tells the user they cannot edit the field and why. So the focus is taken away from the field to the alert box, and if user tries to click back in the field, they just get the alert box again..., so, the user cannot really get to the field to edit it. BTW, my function code also sets the text in the field to gray so it will look like other disabled textbox fields.

    I would still like to know, however, if there is a list of properties that can be used with e_set.
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    Comment


      #3
      Re: How to disable a grid field if callback conditions are true

      OOPS! using the OnFocus event of this field is a bad idea. Was OK in Working Preview, but in Browser preview, you get caught in a loop. Apparently browser keeps putting focus back on the field after user clicks OK on the alert box, so alert box keeps re popping up and won't stop.

      more work to do.... any ideas?
      Carol King
      Developer of Custom Homebuilders' Solutions (CHS)
      http://www.CHSBuilderSoftware.com

      Comment


        #4
        Re: How to disable a grid field if callback conditions are true

        Originally posted by kingcarol View Post
        I would still like to know, however, if there is a list of properties that can be used with e_set.
        Put a debug(1) statement in your xbasic code. Run the grid from the working preview tab. The debugger will popup. Type in e and press the tab key. A + sign will appear to the left. Expand; look for the icons to the right in the "value" column. Click on the icon to further expand, etc. The e properties vary depending upon which event you are using.

        See attached screen shot...
        Peter
        AlphaBase Solutions, LLC

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


        Comment


          #5
          Re: How to disable a grid field if callback conditions are true

          Thanks, Peter. I tried that but do not find anything there in the list that seems to relate to using '._set'. I typed in the 'e' to look and got a list, but nothing seemed to relate. Then I tried typing in e._ which didn't work at all, and e._set, which also didn't work...

          The code line below does work on my grid, so I know that e._set stuff is available.

          e._set.PROD_CODE.style = "color: gray;"

          I'm wanting a list of properties you can use besides just the .style or .value ones shown in the Alphapedia (http://wiki.alphasoftware.com/User+D...ghlight=e._set)
          Carol King
          Developer of Custom Homebuilders' Solutions (CHS)
          http://www.CHSBuilderSoftware.com

          Comment


            #6
            Re: How to disable a grid field if callback conditions are true

            Originally posted by kingcarol View Post
            ...
            I'm wanting a list of properties you can use ...
            I too wish they would document all this stuff.
            Peter
            AlphaBase Solutions, LLC

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


            Comment


              #7
              Re: How to disable a grid field if callback conditions are true

              Same here, I would love to know how to programatically turn an entire form from editable to RO or vice versa. My current work around is to use the Enable Expression for each field on the layout, a bit painful when there are a dozen+ fields in the form.

              Comment


                #8
                Re: How to disable a grid field if callback conditions are true

                I also use the Enable Expression on the same grid I'm referring to because there are specific values in PROD_CODE that can never be changed. But it doesn't cover being able to do an Ajax callback to find out if a the value in a field is used in another table, so, yes, being able to code the enable will be helpful for many things, I think.
                Carol King
                Developer of Custom Homebuilders' Solutions (CHS)
                http://www.CHSBuilderSoftware.com

                Comment


                  #9
                  Re: How to disable a grid field if callback conditions are true

                  Originally posted by Peter.Greulich View Post
                  I too wish they would document all this stuff.
                  it is documented.

                  here is the link

                  http://www.alphafivewiki.com/User+De...s+in+Grids+V10

                  Comment


                    #10
                    Re: How to disable a grid field if callback conditions are true

                    Disabled is the javascript property you are looking for.

                    e._set.PROD_CODE.disabled = "true"

                    Comment


                      #11
                      Re: How to disable a grid field if callback conditions are true

                      Selwyn - That is the very same page that I have already referred to a couple of times in this thread. Since the only properties it seems to refer using e.set are .value, .style, and .classname, are we to assume that those are the only ones available for e._set. ? Does that mean there is no way to set the enable property of the field via code?, or other properties of the field?

                      There is NOT a good list of the properties in that article, and that's what we are wishing we had.
                      Carol King
                      Developer of Custom Homebuilders' Solutions (CHS)
                      http://www.CHSBuilderSoftware.com

                      Comment


                        #12
                        Re: How to disable a grid field if callback conditions are true

                        Marvin - Does that mean we can use Javascript with e._set for any of the fields' properties? That would be a nice tip for Alpha to put in the article.

                        edited - I think I should have said Jeff, instead of Marvin.
                        Carol King
                        Developer of Custom Homebuilders' Solutions (CHS)
                        http://www.CHSBuilderSoftware.com

                        Comment


                          #13
                          Re: How to disable a grid field if callback conditions are true

                          Originally posted by gaby_h View Post
                          Same here, I would love to know how to programatically turn an entire form from editable to RO or vice versa. My current work around is to use the Enable Expression for each field on the layout, a bit painful when there are a dozen+ fields in the form.
                          this is really a javascript question, not an Alpha Five question, but here is the answer anyway:

                          if you want this for a grid then

                          1. add this function to your Javascript function declarations section


                          Code:
                          function toggleReadOnly(rowNum) {
                          
                          	var pEle = $('{grid.componentname}.R' + rowNum);
                          	
                          	//read the value of the special attribute we store in the HTML
                          	var state = $ga(pEle,'STOREREADONLYSTATE');
                          	
                          	//convert a string to a boolean value
                          	if(state == 'true') state = false;
                          	else state = true;
                          
                          
                          	var eles = pEle.getElementsByTagName('input');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          	
                          
                          	eles = pEle.getElementsByTagName('select');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          
                          	eles = pEle.getElementsByTagName('textarea');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          
                          
                          	//store the state in the special attribute
                          	$sa(pEle,'STOREREADONLYSTATE',''+state);
                          }
                          Next, put a button in the Grid. Use text mode (not action javascript) and define this code:

                          Code:
                          toggleReadOnly({Grid.RowNumber});
                          If, on the other hand you want to do this for the Detail view, then define this as your javascript function in Javascript function declarations:

                          Code:
                          function toggleReadOnly() {
                          
                          	var pEle = $('{grid.componentname}.DETAILVIEW_PART.FORM');
                          	
                          	//read the value of the special attribute we store in the HTML
                          	var state = $ga(pEle,'DETAILVIEWREADONLY');
                          	
                          	//convert a string to a boolean value
                          	if(state == 'true') state = false;
                          	else state = true;
                          
                          
                          	var eles = pEle.getElementsByTagName('input');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          	
                          
                          	eles = pEle.getElementsByTagName('select');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          
                          	eles = pEle.getElementsByTagName('textarea');
                          	for(var i = 0; i < eles.length; i++) {
                          		eles[i].readOnly = state;
                          		eles[i].disabled = state;
                          	}
                          
                          
                          	//store the state in the special attribute
                          	$sa(pEle,'DETAILVIEWREADONLY',''+state);
                          }
                          then, put this in the code for your button:

                          Code:
                          toggleReadOnly();

                          Comment


                            #14
                            Re: How to disable a grid field if callback conditions are true

                            Originally posted by kingcarol View Post
                            Selwyn - That is the very same page that I have already referred to a couple of times in this thread. Since the only properties it seems to refer using e.set are .value, .style, and .classname, are we to assume that those are the only ones available for e._set. ? Does that mean there is no way to set the enable property of the field via code?, or other properties of the field?

                            There is NOT a good list of the properties in that article, and that's what we are wishing we had.

                            The generic ajax callback can send ABSOLUTELY ANY javascript that you want back to the client machine. so ABSOLUTELY ANYTHING that you want to do in the browser that can be done in Javascript can be accomplished by an ajax callback that uses Xbasic to compute some javascript code on the server and then sends that javascript back to the client.

                            the javascript that is computed on the server can be as complex as you want.

                            the e._set object that you can use in your callback is just a convenience to help you do some of the more common things that are done in a callback.

                            it in NO WAY limits what you can do.

                            so, say you want to set a control to be disabled in a callback.

                            your callback would compute the following javascript and sent it to the client (assume the control is 'LASTNAME' in row 3 of the Grid):

                            $('{grid.componentname}.V.R' + 3 + '.LASTNAME').disable = true;

                            if you are comfortable writing this code, then great.

                            if you want to use a more convenient syntax, then you can write:

                            e._set.lastname.disable = .t.

                            behind the scenes, a5 will convert this to

                            $('{grid.componentname}.V.R' + 3 + '.LASTNAME').disable = true;

                            the function that a5 uses to convert to javascipt is a5GridHelper_generateAutoAjaxResponse()

                            you can test this function for yourself in the interactive window


                            e.g.

                            type:

                            e._set.lastname.disable = .t.
                            ?a5GridHelper_generateAutoAjaxResponse(e,"G","3")

                            Comment


                              #15
                              Re: How to disable a grid field if callback conditions are true

                              Yay.... whole new world opening up for me. Thanks, Selwyn.
                              Carol King
                              Developer of Custom Homebuilders' Solutions (CHS)
                              http://www.CHSBuilderSoftware.com

                              Comment

                              Working...
                              X