Skip to content

Commit f187f96

Browse files
Update README.md
1 parent ba28cc2 commit f187f96

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

README.md

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
1-
# DatraTable-Paginator
2-
This component is uses to split your records in lightning:datatable into separate pages
1+
# DataTable-Paginator
2+
Component that wraps lightning:datatable and split records into separate pages.
3+
4+
It finds only first aura:iteration tag, other aura:iteration tags would be ignored
5+
6+
Example of using this component:
7+
8+
```
9+
<c:DataTablePaginator elementsPerPage="{!v.recordsPerPage}" items="{!v.data}">
10+
11+
<lightning:datatable keyField="Id" columns="{!v.columns}"/>
12+
13+
</c:DataTablePaginator>
14+
```
15+
As you can see in example, you don't need to put value into data attribute in lightning:dataTable. It's automatically splits records to pages and fills in by DataTablePaginator, where you need to put your records into "items" attribute.
16+
17+
[![DataTablePaginator](https://github.com/leshchukandrej/DataTable-Paginator/blob/master/DatraTablePaginator.png)](https://github.com/leshchukandrej/DataTable-Paginator/blob/master/DatraTablePaginator.png)
18+
19+
You can use Paginator with dynamically loaded elements. For using DataTablePaginator in this case, you should put in attribute isRecordsLoadsDynamically value "true" and handle onChangePage event. In this event, you will receive "offset" and "itemsPerPage" attributes by wich you should query records with OFFSET and LIMIT values in SOQL.
20+
Example of using:
21+
22+
```
23+
<c:DataTablePaginator isRecordsLoadsDynamically="true"
24+
elementsPerPage="{!v.itemsPerPage}" shownItems="{!v.records}"
25+
onChangePage="{!c.loadSpecificRecords}" pages="{!v.pages}">
26+
27+
<lightning:datatable keyField="Id" data="{!v.records}" columns="{!v.columns}"/>
28+
29+
</c:Paginator>
30+
31+
```
32+
### Attention!!! When you receive this values from Lightning Components in Apex methods, you should always transform received values into Integer even you received an integer values.
33+
Like this:
34+
35+
Integer limitValue = Integer.valueOf(variable1)
36+
Integer offsetValue = Integer.valueOf(variable2)

0 commit comments

Comments
 (0)