SPFilterDropDown: Sort Descending

Jan 16, 2013 at 4:44 PM

As a newbie, I assume I'm doing something wrong.  I got SPFilterDropDown to work using column SortOrder from the parent list.  However I need the list in descending order. But when i traced through the code, I could not see a way for <OrderBy> in the camlQuery to get an "Ascending='FALSE'". 

I can tweak the SPFilterDropDown and make it work using a new arguement (e.g. relationshipListSortAscending), but I'd rather not.

Thanks,Tom

<script type="text/javascript">
  $(document).ready(function() {
    $().SPServices.SPFilterDropdown({
      relationshipWebURL: "/",
      relationshipList: "Plan Dates",
      relationshipListColumn: "Title",
      relationshipListSortColumn: "SortOrder",
      columnName: "Plan Date",
      listName: $().SPServices.SPListNameFromUrl(),
      CAMLQuery: "<IsNotNull><FieldRef Name='Title' /></IsNotNull>",
      debug: true
    });
  });
</script>

Coordinator
Jan 16, 2013 at 4:58 PM

Tom:

I just checked the code, and you're right - I don't have the capability to change the sort order in the function. For now, you could reverse the values in the SortOrder column, I suppose.

I'll add this to the list of enhancements for the next release. I think a new option called relationshipListSortAscending, with values of true or false - default being true - probably makes sense.

M.

Coordinator
Jan 16, 2013 at 4:59 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 15, 2013 at 12:44 PM
You can create a calculated column in your sourcelist with the formula =0-ID to effectively create a mirror of your ID column. Decreasing with every new item.
And sort your relationshipListSortColumn with that.

This is ofcourse only with numerical values.

Eivind
Feb 15, 2013 at 1:11 PM
I've tried doing calculated columns with the ID and it hasn't gone very well. I'm not sure exactly when the trigger occurs but I do know after you create a new record, the calculated field will treat the ID as null. Getting the calculation to update usually involved going into list settings and resetting the formula, or other such nonsense. I've only confirmed this in SP 2007...I don't know how 2010 behaves.
Feb 15, 2013 at 1:34 PM
Oh you're right. I'm sorry I forgot to mention I also had a column that a workflow updates on new items. Copying the ID value, as a workaround.