GithubHelp home page GithubHelp logo

pjbonestroo / pagedlist Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 937 KB

Javascript PagedList component for easily creating paginated lists in the browser.

License: Apache License 2.0

Batchfile 0.46% Python 99.11% JavaScript 0.43%
transcrypt pagedlist javascript-pagedlist-component pagination javascript-paginator pagination-library pagination-functionality

pagedlist's Introduction

PagedList

Javascript PagedList component for easily creating paginated lists in the browser.

PagedList is a javascript library to create html lists (or tables) with pagination and auto rendering features. Columns and buttons can be configured.

Columns are configurable to enable sorting and filtering. Buttons are default shown for each row, but can be configured to be visible dependent on row data. Callback functions can be applied on buttons. The row data will be passed to the callback function when a button is clicked.

The list gets refreshed automatically when the user changes sorting or filtering (or browse to an other page). Refreshing can also be done manually by calling myList.refresh(). Debouncing will prevent too many refreshes.

Columns can be configured to expand and collapse, which inserts and deletes an html-element below the clicked row. Refreshing will keep expanded items intact. It is also easy to make nested lists this way.

The data source can be server-side or client-side. This also means filtering, sorting (and paging) will be done server- or client-side. For server-side you need to implement it yourself. For client-side this library will take care.

Documentation as generated by Sphinx (http://www.sphinx-doc.org/en/stable/) can be found by downloading folder docs\sphinx_build\html\ and opening pagedListDoc.html

This library is generated from Python using Transcrypt https://www.transcrypt.org/

How it looks

The styling is fully customizable, but with some defaults it will look like:

alt text

Installation

Add dependencies to your html file:

Add pagedList.js to your html file, like:

<script src="pagedList.js"></script>`

The Javascript files can be found in the python/__target__/ folder.

Code examples

Add a new list to an existing html element with id=myListId, using PagedList:

var myList = new pagedList.PagedList("#myListId", "http://myURL/getListItems");

Add a column with sorting and filtering capabilities, using addColumn:

var column_one = myList.addColumn("Name", "Name")
     .enableFilter()
     .enableSort();

Define how the column content will be rendered, based on the row data, using itemToHtml (alternatively use itemToElement):

column_one.itemToHtml(function (item) {
     return "<div>" + item.Name + "</div>";
});

Add a button to the list, including style classes, which will be visible dependent on row data, using addButton:

myList.addButton("Edit", "Edit", "btn btn-primary btn-xs")
     .onclick(function (item) {
         console.log("Todo: edit item");
     }).showIf(function (item) {
         return item.CanEdit == true;
     });

For more examples, download the standalone example page (docs/example), which shows a PagedList with data from a fake server.

For the full API, download the Sphinx documentation as described above.

pagedlist's People

Contributors

pjbonestroo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gpg-dev

pagedlist's Issues

Typing for Typescript

Add typing to use this library in a Typescript project, and have linting available.

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.