Sort Cascading Drop Down Parent Column by ID

Jun 18, 2014 at 12:14 AM
Marc - Love your SPServices library! Thanks.
(and I sat in on a number of your seminars at SPTechCon SF 2014 - awesome!)

If i want my Parent column to sort by ID instead of alphabetically, do i use your $().SPServices.SPFilterDropdown function? And do I place it above the cascading function on the form page?

Thanks, Jean
Coordinator
Jun 18, 2014 at 3:12 PM
You're welcome!

You can just add the relationshipListSortColumn option. Check the docs for the details.

M.
Jun 18, 2014 at 5:00 PM
thanks Marc. But, i'm doing something wrong.
i've now brought the ID of the parent list into the relationshipList (WorkPhaseLU:ID)

Work Phase (parent list):
ID - Title
1 - Planning/Preliminary Design
2 - Final Design
3 - Bidding
4 - Construction
...

DocumentAttributes_List (relationship list) columns:
  • DocType (Title)
  • WorkPhaseLU (lookup to Work Phase list)
  • WorkPhaseLU:ID
I've tried:

$(document).ready(function() {
$().SPServices.SPCascadeDropdowns({
relationshipList: "DocumentAttributes_List",
relationshipListParentColumn: "WorkPhaseLU",
relationshipListChildColumn: "Title",
relationshipListSortColumn: "WorkPhaseLU:ID",
parentColumn: "Work Phase",
childColumn: "Resource Type",
debug: true
});
});

and
$(document).ready(function() {
$().SPServices.SPCascadeDropdowns({
relationshipList: "DocumentAttributes_List",
relationshipListParentColumn: "WorkPhaseLU",
relationshipListChildColumn: "Title",
relationshipListSortColumn: "WorkPhaseLU%5Fx003a%5FID", // internal field name
parentColumn: "Work Phase",
childColumn: "Resource Type",
debug: true
});
});

but my parent (Work Phase) column in the edit form still sorts alphabetically instead of by its ID
(see attached)
I know i can add a # in front of each work phase list item, but i'm trying not to do that.
Thanks for the help!

Image
Coordinator
Jun 18, 2014 at 5:25 PM
You don't need to bring the ID column over with the lookup.
relationshipListSortColumn: "ID",
M.
Jun 18, 2014 at 5:37 PM
i tried that first, but that sorts the CHILD column by ID. i'm wanting to sort the parent column by its ID.
parent column looks same as above screenshot, but now child column sorted by ID:

Image
Coordinator
Jun 18, 2014 at 5:41 PM
Oh, I'm sorry! I should read more carefully.

I think this is what you need.
$().SPServices.SPFilterDropdown({
  relationshipList: "Work Phase",
  relationshipListColumn: "Title",
  relationshipListSortColumn: "ID",
  columnName: "Work Phase"
});
M.
Jun 18, 2014 at 5:58 PM
should that go above or below the CascadeDropdowns function? i've tried both but no luck.

i've tried: (my parent list has no space in the name "WorkPhase". i've also tried the GUID)

$().SPServices.SPFilterDropdown({
relationshipList: "WorkPhase",
relationshipListColumn: "Title",
relationshipListSortColumn: "ID",
columnName: "Work Phase"
});

i've also tried:
$().SPServices.SPFilterDropdown({
relationshipList: "WorkPhase",
relationshipListColumn: "Title",
relationshipListSortColumn: "ID",
columnName: "Title"
});

no joy.

in your documentation, it says:

columnName
The DisplayName of the child column in the form

(not the parent column?)
Coordinator
Jun 18, 2014 at 6:07 PM
Based on what I can see, it should be:
$().SPServices.SPFilterDropdown({ 
 relationshipList: "WorkPhase", 
 relationshipListColumn: "Title", 
 relationshipListSortColumn: "ID", 
 columnName: "Work Phase" 
 }); 
The columnName should be the column you want to filter. (I just removed the word child from the docs, which shouldn't have been there.)

Try adding debug: true to see if the function complains about something.

M.
Jun 18, 2014 at 6:12 PM
that makes sense.

but, shoot. still no luck. i'll keep trying.
i've tried placing the FILTER function above and below the cascade function -- makes no difference.

$().SPServices.SPFilterDropdown({
relationshipList: "WorkPhase",
relationshipListColumn: "Title",
relationshipListSortColumn: "ID",
columnName: "Work Phase",
debug:true
});

$(document).ready(function() {
$().SPServices.SPCascadeDropdowns({
relationshipList: "DocumentAttributes_List",
relationshipListParentColumn: "WorkPhaseLU",
relationshipListChildColumn: "Title",
parentColumn: "Work Phase",
childColumn: "Resource Type",
debug: true
});
});

thanks for your help :)
Jun 18, 2014 at 6:14 PM
duh, sorry!! i did not place the (new) filter function INSIDE the (document).ready(function().
now all is working as it should!
you are the master.
:)
Coordinator
Jun 18, 2014 at 6:16 PM
Awesome. Sorry for the side trip above.

M.