7 Replies Latest reply: Nov 15, 2012 11:41 AM by Raghu Nagireddy RSS

    Disable all fields, buttons, etc in Subform

    Community Member
      Is there an easy way to disable the contents of a subform?
        • 1. Re: Disable all fields, buttons, etc in Subform
          pguerett techies
          You can turn the presence of the subform to invisible and all children will be made invisible as well.

          You could get all child nodes of the subform and change their access property to readOnly. I have a script function that accepts a node (in your case a subform) and will get all children of that node....then you can do what you want to them.

          Post your email address and I will send the sample ...if you want it.
          • 2. Re: Disable all fields, buttons, etc in Subform
            If the «subform» already has an «access» attribute on its xml template definition, then you can make the subform and all its descendants read-only by setting the subform's «access» attribute to «readOnly», in JavaScript.
            • 3. Re: Disable all fields, buttons, etc in Subform
              Community Member
              can you show me the code around this? I dont think a subform has an access attribute.
              • 4. Re: Disable all fields, buttons, etc in Subform
                JohnQWestat Community Member

                Could you post that code here?

                • 5. Re: Disable all fields, buttons, etc in Subform
                  Raghu Nagireddy Community Member

                  Will be like this.

                   

                  subformname.access = "readOnly"; //javaScript

                  $.access = "readOnly"; //formcalc

                   

                  update the "subformname" with the name of ur subform which want to make readOnly. Place this on a required event based on ur requirement, both javascript and formcalc sysntaxes are above.

                  • 6. Re: Disable all fields, buttons, etc in Subform
                    JohnQWestat Community Member

                    Raghu,

                    Thank you for your response.  My request was intended to be a response to pguerette's post:

                     

                     

                    You could get all child nodes of the subform and change their access property to readOnly. I have a script function that accepts a node (in your case a subform) and will get all children of that node....then you can do what you want to them.

                     

                    Post your email address and I will send the sample ...if you want it.

                    If anyone has this code, that is what I was asking for.

                    • 7. Re: Disable all fields, buttons, etc in Subform
                      Raghu Nagireddy Community Member

                      If need only at "subform" level please check the thread: http://forums.adobe.com/message/4389004#4389004

                       

                      If need at "form root" level, Please check the below function.Pass "oParentNode" as root of the form.

                       

                      function traverse(oParentNode)

                      {

                                var allChildElements;

                                var intNumElements;

                                var currentElement;

                                var i;

                                var j;

                       

                                // Get all occurances of the parent element

                                intNumOccurances = oParentNode.all.length;

                       

                                for (i=0; i < intNumOccurances; i++)

                                {

                                          oCurrentParent = oParentNode.all.item(i);

                       

                                           // Get all the child nodes of the parent element

                                          allChildElements = oCurrentParent.nodes;

                       

                                          // Total number of elements in the object

                                          intNumElements = allChildElements.length;

                       

                       

                                          // Loop through all the child elements

                                          for (j=0; j < intNumElements; j++)

                                          {

                                                    currentElement = allChildElements.item(j);

                       

                                                    // If the element is another subform we'll recursively call the function again

                                                    if (allChildElements.item(j).className == "subform")

                                                    {

                                                              traverse(currentElement);

                       

                                                              // If the objects are fields or exclusive groups then we'll encode them

                                                    } else {

                                                              if (currentElement.className == "field" || currentElement.className == "exclGroup")

                                                              {

                                                                        //Here have the access for both field and value

                                                       //your code comes here

                                                                        fields += currentElement.name + "\t";

                                                                        values += currentElement.rawValue + "\t";

                       

                       

                                                                }

                                                    }

                                          }

                                }

                      }          // end traverse function

                       

                      Hope it may helps.