3 Replies Latest reply: Jul 5, 2014 3:22 AM by bmandava RSS

    Can we create dependent choice list in WCS ?

    PraveenKM

      Hello Everyone,

      Is there any way to create a dependent choice list in WCS ?

      Based on the value/option i select from the parent dropdown , the child dropdown should be filled automatically with the appropriate values.

      Thanks in Advance

       

      Regards,

      Praveen

        • 1. Re: Can we create dependent choice list in WCS ?
          Enrique Varas

          Hello ,

           

          It is totally posible. We have done it in the current project we are working at the moment. Pretty much what we do is to create an attribute editor that retrieves the values and then, we use jQuery functions that fill the fields.

           

          Kind regards,

           

          Enrique

          • 2. Re: Can we create dependent choice list in WCS ?
            PraveenKM

            Thanks a lot Enrique , for your update .

             

            Can you please provide a sample code if possible ? It would really help me a lot .

             

            Regards,

            Praveen

            • 3. Re: Can we create dependent choice list in WCS ?
              bmandava

              You can write your custom dependent choice list with simple code

               

              1. Create a Parent Asset Type & Flext Asset Type which is child.

              2. Load the parent asset types and generate a drop-down list.

              <select name="feature" id="feature">

              <option value="">--</option>

              <!-- looping the list of feature categories -->

              <ics:listloop listname="featureCategoriesList">

              <!-- getting the name and id field's values -->

              <ics:listget fieldname="name" listname="featureCategoriesList" output="featureTitle" />

              <ics:listget fieldname="id" listname="featureCategoriesList" output="featureId" />

              <option value='<ics:getvar name="featureId"/>'><ics:getvar name="featureTitle"/></option> 

              </ics:listloop>

              3. Write javascript code to make ajax call to get the list of child items

              var featureCId = $("#feature").val();

              var serviceUrl = "<%=ics.GetVar("serviceUrl") %>";

              var serviceUrl = serviceUrl+"&fcid="+featureCId;

               

              //sending sub features data

              $.get(

                   serviceUrl,

                   function(resData){

                   ..}

              }

              4. Write a template for Ajax call

              <ics:listloop listname="featuresList">

              <ics:listget fieldname="childid" listname="featuresList" output="fid"/>

              <asset:load name="feature" type="Feature" objectid='<%= ics.GetVar("fid") %>'/>

              <asset:get name="feature" field="name" output="fname"/>

              <asset:get name="feature" field="id" output="fid"/>

              {"name":"<ics:getvar name="fname"/>","id":"<ics:getvar name="fid"/>"},

              </ics:listloop>

               

              Here is the full article:

              Create dependent choice list in webcenter sites - Devble