cancel
Showing results for 
Search instead for 
Did you mean: 

Show file listing in document library tree

purohitsumit
Champ in-the-making
Champ in-the-making
Hi All,

I am trying to reuse documentlibrary component in web-view dashlet. I found this helpful link

http://stackoverflow.com/questions/13363398/alfresco-share-sites-dashlet-for-document-library


Current documentlibrary tree lists folders only under the tree, individual files are only listed in the right regions of the page( where it list all available actions to each file also).

Is there a way to list file names also in the tree, in addition to folders name.
I want to show it something like this:
<code>
Library
|
|Documents |
     |
     |folder1
     |file1.txt
     |file2.jped
     |file3.pdf

What files should i change in order to get combined listing as shown above.

<code>
Thanks


10 REPLIES 10

ddraper
World-Class Innovator
World-Class Innovator
The JavaScript widget that creates the tree can be found in /Slingshot/source/web/components/documentlibrary/tree.js (in the source tree). This calls a REST API to retrieve folders to populate the tree. When you reach a folder "leaf" node then you'll need to call a different REST API (the same one used by documentlist.js widget to populate the DocLib) to get the actual files.

purohitsumit
Champ in-the-making
Champ in-the-making
Thanks for reply….
But what is corresponding location of tree.js in the deployed web app…i have "tree.js" file in

/opt/alfresco-4.2.c/tomcat/webapps/share/components/documentlibrary/tree.js 

but this does not seem to affect the functionality….

mitpatoliya
Star Collaborator
Star Collaborator

ddraper
World-Class Innovator
World-Class Innovator
That is the correct corresponding location on the deployed web app…. how do mean that it doesn't affect the functionality? It defines the "Alfresco.DocListTree" widget which is used to render the tree in the side bar of the Document Library. That widget creates the actual tree (a YAHOO.widget.TreeView widget) and controls it's overall behaviour.

purohitsumit
Champ in-the-making
Champ in-the-making
what i mean by saying "does not affect" is that I tried changing this file by adding alert statement and refreshing page, i even deleted file expecting error. but nothing changed, even after restart.

On html source page, it looks getting some minified js file like


"script type="text/javascript" src="/share/res/components/documentlibrary/tree_dc1145d846bf3d93802aab190eb1ffc.js"></script>"

so i think i may be changing wrong file.

thanks

ddraper
World-Class Innovator
World-Class Innovator
The file you're seeing should be the same file with an MD5 checksum appended to the end - this allows us to set an infinite expiry date on the resource and ensures that the browser cache will never contain stale data because if the file contents changes the MD5 checksum will change and the browser will be forced to request the new version of the file. Surf caches the resources more aggressively than ever before so you may need to click on the "Clear Dependency Cache" button on the WebScripts home page to avoid restarting the server. If the file you're seeing is minified then it suggests that you're running in production mode and the Surf will be finding the pre-minified JavaScript resource. If you update the surf.xml file so that Surf is running with "client-debug" set to true then the non-minified version of the file (the one that you've changed will be loaded).

purohitsumit
Champ in-the-making
Champ in-the-making
That really helped..I was running it in "production mode" and i changed "clinet-debug" to "true" in "share-config.xml" file (i could not find same entry in "surf.xml").
Now i de see changes made my by on page refresh.

But when you said
 "When you reach a folder "leaf" node then you'll need to call a different REST API (the same one used by documentlist.js widget to populate the DocLib) to get the actual files."


i want to show files AND folders  at each level, not just "leaf". Can i some how merge response from two REST call ?


and how can i call//access document list widget from tree widget ?

sorry for these basic questions, my experience with alfresco share development  is minimal.

Thanks

I tried to re-use the code in "documentlist.js"



         // Create a new tree
         var tree = new YAHOO.widget.TreeView(this.id + "-treeview");
         var fpanel = Dom.get("alf-filters"),
             offset = (fpanel ? parseInt(fpanel.style.width, 10) : 160) + 390;
         var columnDefinitions =
         [
           // I deleted column entries
         ];

         // DataTable definition
         this.dataSourceUrl = $combine(Alfresco.constants.URL_SERVICECONTEXT, "components/documentlibrary/data/doclist/");
         this.widgets.dataSource = new YAHOO.util.DataSource(this.dataSourceUrl,
         {
            responseType: YAHOO.util.DataSource.TYPE_JSON,
            responseSchema:
            {
               resultsList: "items",
               metaFields:
               {
                  paginationRecordOffset: "startIndex",
                  totalRecords: "totalRecords",
                  totalRecordsUpper : "totalRecordsUpper" // if null then totalRecords is accurate else totalRecords is lower estimate (if -1 upper estimate is unknown)
               }
            }
         });
         this.widgets.dataTable = new YAHOO.widget.DataTable(this.id + "-treeview", columnDefinitions, this.widgets.dataSource,
         {
            renderLoopSize: this.options.usePagination ? 16 : Alfresco.util.RENDERLOOPSIZE,
            initialLoad: false,
            dynamicData: true,
            MSG_EMPTY: this.msg("message.loading")
         });

          this.widgets.dataTable.doBeforeLoadData = function DL_doBeforeLoadData(sRequest, oResponse, oPayload)
         {
          alert(oResponse.results.length);
          for (var i = 0, ii = oResponse.results.length; i < ii; i++)
               {
                  alert(oResponse.results.node.toSource());
                  oResponse.results.jsNode = new Alfresco.util.Node(oResponse.results.node);
               }
      };   
          this.widgets.dataTable.fireEvent("renderEvent",
               {
                  type: "renderEvent"
               });
         this.widgets.treeview = tree;



It does not break tree creation from tree.js but does not return anything from dataTable widget. I think my call back is incorrect.

Any help will be appreciated.
Thanks

zladuric
Champ on-the-rise
Champ on-the-rise
You don't have any column definitions?