3 Replies Latest reply on Nov 29, 2012 10:34 AM by rush_pawan

    disabling a multifield based on selection

    minisanu Level 1

      Hi  rush_pawan,


      I have three tabs dynamically created with the help of ur your suggestion given above. It works fine.

       

      I have another requirement. If i select one tab amongt the three, there is a drop down list with values and a multifield(textbox). If select a particular value in drop down list the multifield should be diasbled.

       

      It works well for a dialog of xtype dialog.

       

      function(box,value){var ans = box.findParentByType("dialog").form.findField("anstext"); disableAnsText(ans,value);}

      function disableAnsText(ans,value)

      {

         if(value == "date") {

                          alert("anstype value - "+value);

                    ans.setDisabled(true);

          }

       

      }

       

      Now i have 3 tabs in a dialog of xtype tabpanel. How can i achieve the same with the tabpanel.

       

      Thanks. It would be of great help  if i get an answer for this.

        • 1. Re: disabling a multifield based on selection
          rush_pawan Level 4

          Hello Mini,

           

          I hope you have written this listener on component where you want to track event (for example multifield), if that is the case then please search for parent by its xtype (same as above) lets say "panel" as xtype if your tab has xtype as "panel" and use box.findParentByType("panel").form.findField("anstext"); (I hope as you have mentioned you have used tabpanel an insided tabpanel you have multiple tabs).

           

          Let me know if doesn't helped you or any issue.

           

          Also plz refer http://dev.day.com/docs/en/cq/current/widgets-api/index.html for more inforamtion related to any xtype and methods/events associated.

           

          Thanks,

          Pawan

          • 2. Re: disabling a multifield based on selection
            minisanu Level 1

            I tried it...it is not working for me. My dialog is of xtype tabpanel.I have a multifield and if i click on it there will be four fields. Among that fields, if i select a drop down value, the next field anstext which is a multifield should be disabled.

             

            How can i achieve that?Please suggest me something

            • 3. Re: disabling a multifield based on selection
              rush_pawan Level 4

              Hi Mini,

               

              Create a listener node (as you created earlier) to selection node and override the "selectionchanged" event as below

               

              function(box,value){alert("calling function"+value); if(value=="firstvalue"){box.findParentByType('tabpanel').getComponent("first").getCompone nt("mymultifield").disable(this); }}

               

              Taking an example to explain above code - Let say you have tabpanel and inside tabpanel you have one tab "first" of xtype "panel" and that tab is having a

               

              mulltifield - let say "mymultifield"

              selection - dropdown values are "firstvalue, secondvalue, thirdvalue etc..."  and on selection of "firstvalue" you want to disable the multifield.

               

              to execute above code do this.

               

              1. create an "id" property in "first" tab and give value "first"

              box.findParentByType('tabpanel').getComponent("first") - will bring the component under tabpanel having "id" as "first" so you can modify according to your case.

               

              2. create an "id" property in mymultifield with value let say "mymultifield"

              box.findParentByType('tabpanel').getComponent("first").getComponent("mymultifield") - will bring the component under tab having "id" as "mymultifield" (Multifield widget) so you can modify according to your case

               

              3. Now when you do the selection chagne in your select drop down it will fire the even and the value associated to corresponding selected item will be passed as "value" property in event method "function(box,value)" - provided alert to see the value comes in.

               

              4. Now as per above example when you select the dropdown with "firstvalue" in it the value will pass to event and event will check for condition (above code) and based on that it will disable it.

               

               

              for more information about events and property take help from

              http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.Selection

              http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.Ext.TabPanel

              http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.Ext.Panel

               

              I hope above helps you. let me know if it doesn't work.

               

               

              Thanks,

              Pawan