display more than 50 rows with share

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Customer

display more than 50 rows with share

Hello, I wanted to know how to display more than 50 documents, which is the default configuration alfresco, I am using alfresco 5.0.b. The solution indicated here https://hub.alfresco.com/t5/alfresco-content-services-forum/more-then-50-rows-per-page-in-datalist/m... does not work

4 Replies
Highlighted
Moderator
Moderator

Re: display more than 50 rows with share

Look at this post, it may be helpful: 

https://hub.alfresco.com/t5/alfresco-content-services-forum/limiting-the-number-of-documents-shown-o...

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)
Highlighted
Master

Re: display more than 50 rows with share

The thread you referenced is for the data lists page, which is different than the document library page.

The simplest option would be to create a Surf extension module and target the documentlist-v2.get web script with a post processor / controller customisation. You can then find the DocumentList widget in the model.widgets variable, and add a pageSize configuration property to it. This configuration property is supported out-of-the-box, but not set in the default web script controller. A tutorial on extending web script controllers can be found in the documentation - a similar page should also exist for Alfresco 5.0.

Is there any reason you are still using such an old version, and not even a stable version (5.0.b was essentially a development / early access release)?

Highlighted
Customer

Re: display more than 50 rows with share

Thanks, but it didn't work, I specifically need to show more results when I check the trashcan

Highlighted
Moderator
Moderator

Re: display more than 50 rows with share

Whatever @afaust directed is the way to create surf extension. You did not mention earlier about the trashcan. Question initially seemed like you want to change the pageSize to more than 50 in document library. I had done this in the past.

There is a little bit difference in paginator component for document library and trash can. Both can be extended to set the value as per need. Paginator in document library provides widget option for pageSize which can be extended just by updating the pageSize option in documentlist-v2.get.js webscript. Whereas pageSize is setup directly in a yui widget (usertrashcan.js) file. 

You should defitely look at the document link provided earlier by alex if not aware of creating surf extensions. After understandin this document,  Follow these steps to update the pageSize for document library and trashcan:

1- Add a new Surf Extension Modules file called custom-share-extension-modules.xml to the <yourShareProject>/src/main/resources/alfresco/web-extension/site-data/extensions directory.

Create folder structure as: com/demo/components/documentlibrary under extensions folder

<extension>
	<modules>
		<module>
			<id>Custom_Share_Module_Extension</id>
			<version>1.0</version>
			<auto-deploy>true</auto-deploy>
			<customizations>
				<!-- Extend the document library to display 100 files per page. -->
				<customization>
					<targetPackageRoot>org.alfresco.components.documentlibrary</targetPackageRoot>
					<sourcePackageRoot>com.demo.components.documentlibrary</sourcePackageRoot>
				</customization>

				<!-- Extend the trashcan to display 100 files per page. -->
				<customization>
					<targetPackageRoot>org.alfresco.components</targetPackageRoot>
					<sourcePackageRoot>com.demo.components</sourcePackageRoot>
				</customization>
			</customizations>
		</module>
	</modules>
</extension>

2- Create a file "documentlist-v2.get.js" under  com/demo/components/documentlibrary folder as setup above (use surf bug to identify which file to extend for which component. Look at this document here: https://docs.alfresco.com/5.2/concepts/dev-extensions-share-surfbug.html)

3- Add following code to the documentlist-v2.get.js file, see highlighted line:

<import resource="classpath:/alfresco/site-webscripts/org/alfresco/components/documentlibrary/include/toolbar.lib.js">
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/components/upload/uploadable.lib.js">
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/components/documentlibrary/include/documentlist.lib.js">

doclibCommon();

function widgets()
{
  //Show 100 files per page. Default value was 50
  model.widgets[1].options.pageSize = 100;
}

widgets();

This controller will be processed after the out-of-the-box documentlist-v2 controller. 

4- By following the same above steps, find the out-of-the-box user-trashcan webscript files (see the list of files below which needs to be copied) and copy them under com/demo/components/ folder

user-trashcan.get.html.ftl
user-trashcan.get.js

Here we are going to extend the YUI widget itself by overriding the pageSize value in usertrashcan.js 

5- Find "usertrashcan.js" out-of-the-box file (can be found under /components/profile/usertrashcan.js) and copy under <yourProject>/src/main/resources/META-INF/components/profile/ folder. Rename it to : "usertrashcan-custom.js"

6- Edit the usertrashcan-custom.js file and update the pageSize value, see highlighted. 

 // Declare namespace
if (typeof Custom == undefined || !Custom) { var Custom = {}; }
if (!Custom.Alfresco) { Custom.Alfresco = {}; }
if (!Custom.Alfresco.UserTrashcan) { Custom.Alfresco.UserTrashcan = {}; }

/**
 * Custom User Trashcan component.
 * 
 * @namespace Alfresco
 * @class Alfresco.UserTrashcan
 */
(function()
{
   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom,
       Event = YAHOO.util.Event;
   
   /**
    * Alfresco Slingshot aliases
    */
   var $html = Alfresco.util.encodeHTML;
   
   /**
    * Custom User Trashcan constructor.
    * 
    * @param {String} htmlId The HTML id of the parent element
    * @return {Custom.Alfresco.UserTrashcan} The new UserTrashcan instance
    * @constructor
    */
   Custom.Alfresco.UserTrashcan = function(htmlId)
   {
      Custom.Alfresco.UserTrashcan.superclass.constructor.call(this, "Custom.Alfresco.UserTrashcan", htmlId, ["button", "container", "datasource", "datatable", "paginator"]);
      this.searchText = "";
      return this;
   }
   
   YAHOO.extend(Custom.Alfresco.UserTrashcan, Alfresco.component.Base,
   {
      searchText: null,
      //Show 100 files per page.
      pageSize: 100,
      skipCount: 0,
      
     ......
....
}

7- Edit the user-trashcan.get.html.ftl file and update the reference to usertrashcan.js to usertrashcan-custom.js:

<@markup id="custom-js" target="js" action="replace">
   <#-- JavaScript Dependencies -->
   <#-- Overridden usertrashcan.js to increase the pageSize from 50 to 100 -->
   <@script src="${url.context}/res/components/profile/usertrashcan-custom.js" group="profile"/>
</@>

8- Edit the "user-trashcan.get.js" file and add following code. Here we are overriding the out-of-the-box UserTrashcan widget:

//Find the default UserTrashcan widget and replace it with the custom widget
for (var i=0; i<model.widgets.length; i++) {
  if (model.widgets[i].id == "UserTrashcan") {
      model.widgets[i].name = "Custom.Alfresco.UserTrashcan";
  }
}

9- Now, restart the server. You should see try uploading 101 files in document library, you should see that 100 files are on page 1 and next page would have 1 file. Now delete all these files and go to trashcan and you should notice the same behavior. 

Note that, in document library you have option to go by page number but in trashcan you have to follow the << >> links.

I have added full file details on my blog here as i was not able to add files with this reply: https://javaworld-abhinav.blogspot.com/2020/01/display-more-than-50-items-per-page-in.html

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)