GithubHelp home page GithubHelp logo

leshchukandrej / datatable-paginator Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 44 KB

This component is uses to split your records in lightning:datatable into separate pages

CSS 0.85% JavaScript 99.15%
lightning-datatable pagination lightning-component salesforce-lightning-component aura salesforce

datatable-paginator's Introduction

DataTable-Paginator

Component that wraps lightning:datatable and split records into separate pages.

It finds only first aura:iteration tag, other aura:iteration tags would be ignored

Example of using this component:

    <c:DataTablePaginator itemsPerPage="{!v.itemsPerPage}" items="{!v.data}">

        <lightning:datatable keyField="Id" columns="{!v.columns}"/>
                                     
    </c:DataTablePaginator>

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.

DataTablePaginator

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. Example of using:

    <c:DataTablePaginator isRecordsLoadsDynamically="true" 
                                      itemsPerPage="{!v.itemsPerPage}" shownItems="{!v.records}" 
                                      onChangePage="{!c.loadSpecificRecords}" pages="{!v.pages}">

          <lightning:datatable keyField="Id" data="{!v.records}" columns="{!v.columns}"/>
          
    </c:Paginator>
    

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.

Like this:

Integer limitValue = Integer.valueOf(variable1);
Integer offsetValue = Integer.valueOf(variable2);

datatable-paginator's People

Contributors

leshchukandrej avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.