cancel
Showing results for 
Search instead for 
Did you mean: 

Document Library sort order

nimbus58
Champ in-the-making
Champ in-the-making
Hello,

I am trying to find a way to sort the documents in the Share Document Library by creation date.
Is it possible and if yes, … how!

Thanks
9 REPLIES 9

mikeh
Star Contributor
Star Contributor
Currently this isn't possible from the UI.

However, if you want to make the change permanently you can update / override the filters.lib.js script on the Repository.
classpath:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js
At the top of the script is the default sort order:
var filterParams =
{
   …
   sortBy: "@{http://www.alfresco.org/model/content/1.0}name",
   sortByAscending: true,
   …
}

Thanks,
Mike

abolotnov
Champ in-the-making
Champ in-the-making
Hi,

I was looking for a way to change my docLib sort order to have all files be sorted by their names. Your posting does help find a way to do this, but it looks like it's not working for me. I have looked at the filters.lib.js and its sort order on creation is set to "name", right. Yet the three test files I have now are sorted this way (by creation date):

Canon.txt
Aaron.txt
Bolton.txt

however, the filters.lib.js file has this:

sortBy: "@{http://www.alfresco.org/model/content/1.0}name",
sortByAscending: true,

please assist, am I doing something wrong?

mikeh
Star Contributor
Star Contributor
It's to do with the underlying Lucene indexing (I believe - I'm no Lucene expert!). I can see it working here, so it will either be working on HEAD or will be merged to HEAD soon.

Thanks,
Mike

nimbus58
Champ in-the-making
Champ in-the-making
Thanks Mike,

Just what I needed!

ssaravanan
Champ in-the-making
Champ in-the-making
In the filters.lib.js look for the following codeline
default:
         var filterQuery = "+PATH:\"" + parsedArgs.parentNode.qnamePath + "/*\"";
         filterQuery += " -ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
         filterParams.query = filterQuery;
         break;

Change that to look like this

default:
         var filterQuery = "+PATH:\"" + parsedArgs.parentNode.qnamePath + "/*\"";
         filterQuery += " -ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
         filterQuery.sortBy = "@{http://www.alfresco.org/model/content/1.0}name";
         filterQuery.sortByAscending = true;
        
         filterParams.query = filterQuery;
         break;

That will make sure that the documents are sorted in the document library
and in the All documents link in the document library

mikeh
Star Contributor
Star Contributor
Hi Saravanan

No - that's not quite correct. The "sortBy" and "sortByAscending" values are members of the filterParams object literal, not the filterQuery string. The default sort order is by name (ascending) but this is overridden for the "recently modified" and "recently added" filters. As I mentioned before, you might need a fairly recent build to pick up on the changes to the query engine which correctly honoured the sortBy parameters.

Thanks,
Mike

zaizi
Champ in-the-making
Champ in-the-making
Had to get this working for a client. So passed the filter param to the freemarker template and did the sorting in freemarker.

mycroes
Champ in-the-making
Champ in-the-making
I was wondering if someone got this working without changing the filters.lib.js in the deployed war. I'm trying to do the same thing (well, for action-sets.lib.js actually), but I can't seem to get it to override the default…
Regards,

Michael

tmeedend
Champ in-the-making
Champ in-the-making
I was wondering if someone got this working without changing the filters.lib.js in the deployed war. I'm trying to do the same thing (well, for action-sets.lib.js actually), but I can't seem to get it to override the default…
Regards,

Michael

I also tried to override this file with a jar. I tried to put it in :
- config\alfresco\templates\webscripts\org\alfresco\slingshot\documentlibrary-v2\filters.lib.js
- config\alfresco\extension\templates\webscripts\org\alfresco\slingshot\documentlibrary-v2\filters.lib.js

Nothing overrided the original file.

The only way I found that worked is to delete the original filters.lib.js. Without the original file, Alfresco uses my custom filters.lib.js (if it's in config\alfresco\templates\webscripts\org\alfresco\slingshot\documentlibrary-v2\filters.lib.js of my jar)

With Alfresco 4.0.2.9