1

I want to populate a cascading dropdownlist from a the same SharePoint list using CAML query.

2 Answers 2

1

You can use SPServices to create Cascade dropdowns.

SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.

For cascade dropdowns you can use the SPCascadeDropdowns function wicht lets you set up cascading dropdowns on SharePoint forms.

$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: "",
  relationshipList: "",
  relationshipListParentColumn: "",
  relationshipListChildColumn: "",
  relationshipListSortColumn: "",
  parentColumn: "",
  childColumn: "",
  CAMLQuery: "",
  CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>", // Added in 2013.01
  listName: $().SPServices.SPListNameFromUrl(), 
  promptText: "",
  simpleChild: false,           // Added in v0.6.2
  selectSingleOption: false,        // Added in v0.6.2
  matchOnId: false,         // Added in v0.7.1
  completefunc: null,
  debug: false
});
0

A SharePoint list is just a table when it comes down to it. There are many ways to access it. For SharePoint 2010 and on your options are:

SharePoint Object Model in C#/VB

ClientObjectModel in Javascript/C#/VB

In SharePoint 2013 you get an added option of a better WebService

As far as making the cascading dropdown, if you have the ability to white the logic yourself, simply create a list what has a Parent column pointing back to itself. Allow it to be null. The Parent items for the first drop down will have no Parent. The second tier will be any item with the selected first tier as the Parent. If there is a third, allow for second tier items to be Parents.

The logic can be implemented actively client side where you make a call back every time there is a list change. The callback can be from Ajax or from a full postback.

If you are more worried about the overall performance of the form rather than the load time, you could load the entire model server side then print the data out to Javascript. You'd be able to switch options client side with no postback.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.