d-scrollable-table
Scrollable table with fixed (floating) thead and N first column(s)
Last updated 2 months ago by maestro.sc .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install d-scrollable-table 
SYNC missed versions from official npm registry.

d-scrollable-table

Scrollable table with fixed (floating) thead and N first column(s)

Usage

app.component( require('d-scrollable-table') );

There are 2 ways to set up scroll handling:

1. (preferred) Bind to container's scroll event

<div style="overflow: auto" on-scroll="scrollable.scroll($element)">
  <view is="d-scrollable-table" as="scrollable"></view>
  <table>
  
    <tbody>
      <tr>
        <!-- 
          IMPORTANT! Cells that should be fixed when scrolling horizontally
          MUST be <th>. So if you want 3 first columns to be fixed when 
          scrolling, make sure that first 3 cells in each row of <tbody>
          are <th> and all the others are <td>
        -->
        <th>Fixed 1</th>
        <th>Fixed 2</th>
        <th>Fixed 3</th>
        
        <td>Normal</td>
        <td>Normal</td>
        <!-- ... -->
        <td>Normal</td>
      </tr>
      <!-- ... -->
      <tr>
        <!-- ... -->
      </tr>
    </tbody>
    
    <thead>
      <!-- 
        IMPORTANT! thead MUST be on the very bottom after <tbody>.
        All browsers will still render it on the top so don't worry.
        All cells must be <th>.
      -->      
      <tr>
        <th>...</th>
        <th>...</th>
        <!-- ... -->
        <th>...</th>
      <tr>
    </thead>
    
  </table>
</div>

2. Bind to the table itself

<view is="d-scrollable-table" as="scrollable" 
      on-create="scrollable.scrollParent($controller.table)"></view>
<table as='table'>
  <!-- ... -->
</table>

Options

  • hiddenClass specifies the class name of hidden <tr>s. It's used in <th>-search algorithm that determines the amount of columns to make float. By default it's u-hidden, so all <tr>s with this class will be omitted.

  • update is any variable that you can pass to listen for its changes and force update the table (useful when your columns may change dynamically)

Licence

MIT

Current Tags

  • 0.4.2                                ...           latest (2 months ago)

10 Versions

  • 0.4.2                                ...           2 months ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |