留言板

pagination in portlet

smith ola lekan,修改在9 年前。

pagination in portlet

New Member 帖子: 7 加入日期: 08-11-19 最近的帖子
Hi all,
can somebody show me the steps to page a large resultset in portlet without using the liferay contaniner (search)

Thank you .
thumbnail
Ravi Kumar Gupta,修改在9 年前。

RE: pagination in portlet

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
You could use datatables. https://www.datatables.net/

Or some other plugin similar to that. Also, I believe you're already aware that, while getting results, you can use start and end in the methods. Like for getting users you could use UserLocalServiceUtil.getUsers(start, end).
thumbnail
David H Nebinger,修改在8 年前。

RE: pagination in portlet

Liferay Legend 帖子: 14914 加入日期: 06-9-2 最近的帖子
There's nothing magical to the implementation.

You basically have to know how many total rows (to display paging information) and keep a "cursor" where the user is in the current content. The "first page" button resets your cursor to index 0, the previous page button subtracts the page count from the cursor (without letting it get to zero), next page adds the page count (without letting it exceed total records) and last page sets cursor to the last page of records ((total count / page count) kind of thing adjusted for remainders or not).

You then include page count records beginning at cursor.

Search container isn't so bad. Liferay, for example, uses a search container for the forum threads and handles the pagination over the results. It's capable of handling quite complex rendering scenarios, so perhaps it can still work for you.
thumbnail
Praful Shukla,修改在8 年前。

RE: pagination in portlet

Junior Member 帖子: 46 加入日期: 15-9-29 最近的帖子
David H Nebinger:
There's nothing magical to the implementation.

You basically have to know how many total rows (to display paging information) and keep a "cursor" where the user is in the current content. The "first page" button resets your cursor to index 0, the previous page button subtracts the page count from the cursor (without letting it get to zero), next page adds the page count (without letting it exceed total records) and last page sets cursor to the last page of records ((total count / page count) kind of thing adjusted for remainders or not).

You then include page count records beginning at cursor.

Search container isn't so bad. Liferay, for example, uses a search container for the forum threads and handles the pagination over the results. It's capable of handling quite complex rendering scenarios, so perhaps it can still work for you.


Hi David,
I want to know that how could I implement Liferay's search container in my Dynamic Data List using Custom Display Template.
I have created a DDL for my Customers and using the following Display Template to get information regarding my customers:

#if (!$records.isEmpty())
<table id="data-table" class="table table-bordered table-hover table-striped">
<thead class="table-columns">
<th class="table-first-header" >Customer ID</th>
<th class="" >Name</th>
<th class="" >Address</th>
</thead>
#foreach ($cur_record in $records)
<tr>
<td>$cur_record.getFieldValue("Custome_ID", $locale)</td>
<td>$cur_record.getFieldValue("Name", $locale)</td>
<td>$cur_record.getFieldValue("Address", $locale)</td>
</tr>
#end
</table>
#end

Now I want to Paginate it,as the list is getting longer and longer day by day.
Can you help me with this.Any help is appreciated.


Thanks & Regards,
Praful
thumbnail
Neha Goyal,修改在8 年前。

RE: pagination in portlet

Regular Member 帖子: 121 加入日期: 13-5-14 最近的帖子
Please try this

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.js"></script>

<script>
$(document).ready(function(){
//For Pagination with DataTable
$('table#data-table').dataTable( {
"paging": true,
"searching":false,
"info": false
});
});
</script>

#if (!$records.isEmpty())
<table id="data-table" class="table table-bordered table-hover table-striped">
<thead class="table-columns">
<th class="table-first-header" >Customer ID</th>
<th class="" >Name</th>
<th class="" >Address</th>
</thead>
#foreach ($cur_record in $records)
<tr>
<td>$cur_record.getFieldValue("Custome_ID", $locale)</td>
<td>$cur_record.getFieldValue("Name", $locale)</td>
<td>$cur_record.getFieldValue("Address", $locale)</td>
</tr>
#end
</table>
thumbnail
Praful Shukla,修改在8 年前。

RE: pagination in portlet

Junior Member 帖子: 46 加入日期: 15-9-29 最近的帖子
Hello Neha,
I have implemented the script provided by you,but it is not working.
Is there is any thing extra that I need to do,I mean to say that do I have to
download some kind of CSS or JS file and upload it somewhere..??
thumbnail
Neha Goyal,修改在8 年前。

RE: pagination in portlet

Regular Member 帖子: 121 加入日期: 13-5-14 最近的帖子
Praful Shukla:
Hello Neha,
I have implemented the script provided by you,but it is not working.
Is there is any thing extra that I need to do,I mean to say that do I have to
download some kind of CSS or JS file and upload it somewhere..??


Please give a try to this teplate:

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.js"></script>

<script>
$(document).ready(function(){
//For Pagination with DataTable
$('table#data-table').dataTable( {
"paging": true,
"searching":false,
"info": false
});
});
</script>

#if (!$records.isEmpty())
<table id="data-table" class="table table-bordered table-hover table-striped">
<thead class="table-columns">
<th class="table-first-header" >Customer ID</th>
<th class="" >Name</th>
<th class="" >Address</th>
</thead>
#foreach ($cur_record in $records)
<tr>
<td>$cur_record.getFieldValue("Custome_ID", $locale)</td>
<td>$cur_record.getFieldValue("Name", $locale)</td>
<td>$cur_record.getFieldValue("Address", $locale)</td>
</tr>
#end
</table>
#end

In my last updated template, you need not to download.Here we are providing cdn which mean template will download when it will loaded on browser.
Look strange why it is not working for you.
Can you open your browser console and check what error you are getting.


Regards:
Neha
thumbnail
Praful Shukla,修改在8 年前。

RE: pagination in portlet

Junior Member 帖子: 46 加入日期: 15-9-29 最近的帖子
Neha Goyal:
Praful Shukla:
Hello Neha,
I have implemented the script provided by you,but it is not working.
Is there is any thing extra that I need to do,I mean to say that do I have to
download some kind of CSS or JS file and upload it somewhere..??


Please give a try to this teplate:

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.js"></script>

<script>
$(document).ready(function(){
//For Pagination with DataTable
$('table#data-table').dataTable( {
"paging": true,
"searching":false,
"info": false
});
});
</script>

#if (!$records.isEmpty())
<table id="data-table" class="table table-bordered table-hover table-striped">
<thead class="table-columns">
<th class="table-first-header" >Customer ID</th>
<th class="" >Name</th>
<th class="" >Address</th>
</thead>
#foreach ($cur_record in $records)
<tr>
<td>$cur_record.getFieldValue("Custome_ID", $locale)</td>
<td>$cur_record.getFieldValue("Name", $locale)</td>
<td>$cur_record.getFieldValue("Address", $locale)</td>
</tr>
#end
</table>
#end

In my last updated template, you need not to download.Here we are providing cdn which mean template will download when it will loaded on browser.
Look strange why it is not working for you.
Can you open your browser console and check what error you are getting.


Regards:
Neha


Hi,
Thank you so much Neha,now its working..!!!
thumbnail
Neha Goyal,修改在8 年前。

RE: pagination in portlet

Regular Member 帖子: 121 加入日期: 13-5-14 最近的帖子
Happy to heard that.
Abdur rasheed,修改在8 年前。

RE: pagination in portlet

Junior Member 帖子: 71 加入日期: 08-9-26 最近的帖子
Hi Smith,
Try with Jquery Pagination, we have no. of plugins.
Thanks
Abdur