When you want to have a filtered lookup with your CascadeDropdowns or other from JQuery, you can use the CAML Query. With this query you can “tell” the list dropdown list what items it has to contain.
A very useful program to create CAML Query is U2U CAML Query Builder
For instance (personal usage):
I wanted that my dropdown list only contained who where available for loan, my products needed to be filtered by what type they are part of, so I used the Cascade Dropdown service from JQuery.
My code that realizes my needs:
These following script tags pinpoint to the 2 files that enables the JQuery usage
<script type="text/javascript" language="javascript" src="../../../JQuery Library/jquery-1.5.1.js"></script>
<script type="text/javascript" language="javascript" src="../../../JQuery Library/jquery.SPServices-0.6.0.js"></script>
The following script bloc is the code that I’ve placed in my newItem.aspx
<script type="text/javascript" language="javascript">
$().SPServices.SPCascadeDropdowns({
relationshipList:"Toestellen",
relationshipListParentColumn:"Toesteltyp",
relationshipListChildColumn:"Title",
parentColumn:"Type toestel",
childColumn:"Toestelnaam",
CAMLQuery:"<Eq><FieldRef Name='Status' /><Value Type='Choice'>Beschikbaar</Value></Eq>",
promptText:"Kies een {0}",
debug:true
});
</script>

Geen opmerkingen:
Een reactie posten