Thursday 20 September 2012

Cascading dropdown upto 3 level in Sharepoint 2010


To make the example shown at the top of the page for Country -> Region -> State work, here's what you need to do.
The end result will look like this:



You'll need these three relationship lists:
Countries List The Countries list simply contains all of the country names, stored in the list's Title column.
Regions List The Regions list contains all of the Region names in the Title column. The Country column is a Lookup column into the Countries list's Title column.
 
States List The States list contains all of the State names in the Title column. Note that I've changed the DisplayName of the Title column to State, but the StaticName is still Title. The Region Name column is a Lookup column into the Regions list's Title column. (The State Abbreviation column is only here to show that you can also store additional information about the States in this list. The same is true of the Countries and Regions lists, of course.)
This is the sum total of what you'll need to add to your page to make the function work for the example above. The first two lines simply pull the script files into the page, and the $(document).ready(function() line is a jQuery function that says "Run this script when the page has been fully rendered". In the first call to the function, note that we're turning debug mode on by setting debug: true.
<script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery-1.4.2.js"></script>
<script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery.SPServices-0.5.7.min.js"></script>
NB:Add the  particular version of jquery and spservices otherwise it will not work
<script language="javascript" type="text/javascript">
 $(document).ready(function() {
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "Regions",
   relationshipListParentColumn: "Country",
   relationshipListChildColumn: "Title",
   parentColumn: "Country",
   childColumn: "Region",
   debug: true
  });
  $().SPServices.SPCascadeDropdowns({
   relationshipList: "States",
   relationshipListParentColumn: "Region_x0020_Name",
   relationshipListChildColumn: "Title",
   relationshipListSortColumn: "ID",
   parentColumn: "Region",
   childColumn: "State"
  });
 });
</script>

To add Caml query to filter
CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq>"
To Show the default text Find "Prompttext"  and add  "Choose {0}...",
Ex-Choose Country, Choose State Like this
Reffered From Here




No comments:

Post a Comment