Coder Social home page Coder Social logo

cactusoft-ca / ng-table-virtual-scroll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from diprokon/ng-table-virtual-scroll

0.0 1.0 0.0 3.15 MB

Virtual Scroll for Angular Material Table

Home Page: https://diprokon.github.io/ng-table-virtual-scroll

License: MIT License

JavaScript 0.13% TypeScript 74.94% CSS 0.99% HTML 17.88% SCSS 6.07%

ng-table-virtual-scroll's Introduction

Virtual Scroll for Angular Material Table

An Angular Directive, which allow to use virtual scrolling in mat-table

Demo npm Build & Test License

Table of Contents

NPM

$ npm install -save ng-table-virtual-scroll

Version compatibility

Angular version Library version
>= 15 latest
13 - 14 1.5.*
<= 12 1.3.*

Import TableVirtualScrollModule

import { TableVirtualScrollModule } from 'ng-table-virtual-scroll';

@NgModule({
  imports: [
    // ...
    TableVirtualScrollModule
  ]
})
export class AppModule { }

Note: you need to install and configure virtual scrolling (ScrollingModule) and mat-table (MatTableModule) before. TableVirtualScroll only make them work together properly

Configure the table

Data Source

The TableVirtualScrollDataSource extends the MatTableDataSource and must be used as the data source for the mat-table (CdkTableVirtualScrollDataSource for cdk-table)

Note: without TableVirtualScrollDataSource the directive won't work

import { TableVirtualScrollDataSource } from 'ng-table-virtual-scroll';

@Component({...})
export class MyComponent {

  dataSource = new TableVirtualScrollDataSource();

}

Directive

The tvsItemSize directive makes the magic

<cdk-virtual-scroll-viewport tvsItemSize="48" headerHeight="56" style="height: 400px;">
    <table mat-table [dataSource]="dataSource">
    ...
    </table>
</cdk-virtual-scroll-viewport>

Make sure, you set the height to the <cdk-virtual-scroll-viewport> container

Also, you can provide additional properties:

tvsItemSize -> the row height in px (default: 48)

headerHeight -> the header row height in px (default: 56)

footerHeight -> the footer row height in px (default: 48)

headerEnabled -> is the header row in the table (default: true)

footerEnabled -> is the footer row in the table (default: false)

bufferMultiplier -> the size of rendered buffer. The bufferMultiplier * visibleRowsCount number of rows will be rendered before and after visible part of the table.

CdkTable

cdk-table from CdkTableModule is also supported. Just use CdkTableVirtualScrollDataSource as datasource

Issues

If you identify any errors in the library, or have an idea for an improvement, please open an issue.

ng-table-virtual-scroll's People

Contributors

diprokon avatar etiennesimoneau avatar dependabot[bot] avatar deadmanm avatar plchampigny avatar iuliancmarcu avatar zauni avatar nthornton2010 avatar nightapes avatar

Watchers

James Cloos 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.