Giter VIP home page Giter VIP logo

fixed-data-table's Introduction

Project Status: ๐Ÿšจ Unmaintained ๐Ÿšจ

This project is no longer maintained. We will not be accepting pull requests, addressing issues, nor making future releases.

Alternatives


Fixed Data Tables for React

FixedDataTable is a React component for building and presenting data in a flexible, powerful way. It supports standard table features, like headers, columns, rows, header groupings, and both fixed-position and scrolling columns.

The table was designed to handle thousands of rows of data without sacrificing performance. Scrolling smoothly is a first-class goal of FixedDataTable and it's architected in a way to allow for flexibility and extensibility.

Features of FixedDataTable:

  • Fixed headers and footer
  • Both fixed and scrollable columns
  • Handling huge amounts of data
  • Variable row heights (with adaptive scroll positions)
  • Column resizing
  • Performant scrolling
  • Customizable styling
  • Jumping to a row or column
  • Controlled scroll API allows touch support

Things the FixedDataTable doesn't do:

  • FixedDataTable does not provide a layout reflow mechanism or calculate content layout information such as width and height of the cell contents. The developer has to provide the layout information to the table instead.
  • FixedDataTable does not handle sorting of data. Instead it allows the developer to supply data getters that can be sort-, filter-, or tail-loading-aware.
  • FixedDataTable does not fetch the data (see above)

Getting started

Install fixed-data-table using npm.

npm install fixed-data-table

Add the default stylesheet dist/fixed-data-table.css, then import it into any module.

Basic Example

import React from 'react';
import ReactDOM from 'react-dom';
import {Table, Column, Cell} from 'fixed-data-table';

// Table data as a list of array.
const rows = [
  ['a1', 'b1', 'c1'],
  ['a2', 'b2', 'c2'],
  ['a3', 'b3', 'c3'],
  // .... and more
];

// Render your table
ReactDOM.render(
  <Table
    rowHeight={50}
    rowsCount={rows.length}
    width={5000}
    height={5000}
    headerHeight={50}>
    <Column
      header={<Cell>Col 1</Cell>}
      cell={<Cell>Column 1 static content</Cell>}
      width={2000}
    />
    <Column
      header={<Cell>Col 2</Cell>}
      cell={<MyCustomCell mySpecialProp="column2" />}
      width={1000}
    />
    <Column
      header={<Cell>Col 3</Cell>}
      cell={({rowIndex, ...props}) => (
        <Cell {...props}>
          Data for column 3: {rows[rowIndex][2]}
        </Cell>
      )}
      width={2000}
    />
  </Table>,
  document.getElementById('example')
);

Contributions

Use GitHub issues for requests.

We actively welcome pull requests; learn how to contribute.

Changelog

Changes are tracked as GitHub releases.

License

FixedDataTable is BSD-licensed. We also provide an additional patent grant.

fixed-data-table's People

Contributors

andreyco avatar cpojer avatar difelice avatar dilatorily avatar ehzhang avatar forbeslindesay avatar gillesruppert avatar glau-ck avatar hedgerwang avatar istarkov avatar jartek avatar jbonta avatar joelmarcey avatar joshduck avatar jusio avatar liamcmitchell avatar ludofischer avatar marcneuwirth avatar mikestead avatar miorel avatar mkawalec avatar mnishiguchi avatar pieterv avatar steveluscher avatar sww avatar tomclarkson avatar tp avatar wlis avatar yamyamyuo avatar zpao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fixed-data-table's Issues

headerHeight & rowHeight: Must be used with attribute expressions?

Found that I must use headerHeight & rowHeight with attribute expressions:

Won't Work:
<Table width="1000" height="500" headerHeight="50" rowHeight="50" rowGetter={rowGetter} rowsCount={this.state.data.length}>

Works:
<Table width="1000" height="500" headerHeight={50} rowHeight={50} rowGetter={rowGetter} rowsCount={this.state.data.length}>

Is this bug or intentional?

Bottom row stays fixed and on top of the row above it

The bottom row is staying fixed while scrolling (it does still update when done scrolling). It sits above the row on top of it like this:

screen shot 2015-01-28 at 4 48 01 pm

This happened after scrolling about 3/4 down scrolled up, and then back down again.

Chrome (Mac) Version

screen shot 2015-01-28 at 4 54 14 pm

Type checking via Flow

I notice that this code doesn't include @flow, but it does have @typechecks. Is this something related to Facebook's internal type checking system?

Ways to style the table?

Is there any way to pass className or style to table and cell components? I know I can attach CSS styles directly to generated elements and classes, but that's not very ideal because it generates hard linkings with inner workings of the component which should be opaque to the outside and is subject to changes.

Use default scrollbar without specifying height or maxHeight

Hi all!

Thanks for your work on FixedDataTable.

Currently, it's mandatory to provide a height or a maxHeight to the Table component. I was wondering what's the reason for making this parameter mandatory? Then, is it possible to flatten the table so all the data are displayed on the page using the default scrollbar of the page?

For now, when I have a lot of data which takes more place than the specified table height, a scrollbar appears for the table container. I'd like to display all the data on the page, and use the normal scrollbar.

Any advices?

Thanks

Row spans/grouping

Similar to column grouping, the ability to display row spans/grouping would help show relationships in the data at the row level:

row_span

Scroll and mousewheel don't work in chrome

firefox 37 is working
chrome 39 give me these errors.

ReactWheelHandler.js:44 Uncaught ReferenceError: normalizeWheel is not defined
DOMMouseMoveTracker.js:45 Uncaught ReferenceError: EventListener is not defined 

PS. Also, shouldn't be dependencies like object.assign be in readme? or browser support? at least couple of lines. Thanks.

Performance benchmark?

I was confronted by my colleagues about the advantages of using this component against simply using HTML <table> for rendering and I found I couldn't come up with anything convincing. Most importantly when I mentioned about the alleged performant speed, I can't find any figures to support it. So it might be good if we can come up with performance benchmarks of some sort.

Firefox scrolling performance

Scrolling on Firefox constantly stutters. Tested on FF 35.01 on OS X. Chrome on the same machine is buttery smooth.

A scroll bar for the document keeps appearing while trying to scroll inside the table.

Touch Events

I do not understand how touch events work with this library. There is no call to React.initializeTouchEvents(true) and React pre 0.13 doesnt even have TouchEvents included in the default build. Did you use a custom library for the website or am I missing something? For some reason your event handler in touchable area is being called where mine isnt, did you do anything special to achieve this?

server-side rendering support

Currently the code has some dependencies on the client-side DOM, e.g.

  1. FixedDataTableColumnResizeHandle componentWillMount has dependency on document.body
  2. getActiveElement (which in turn dependent on document.body) is used

Is there a plan to make this component support isomorphic application?

Thanks.

Handling large number of columns

Have you given any thought to handling cases (like time-series data) where the number of columns, rather than rows, is large?

We wrote a virtualizing grid (using Knockout) for that scenario, because as far as we could tell, none of the existing table libraries handled it well, if at all. The primary problems were:

  • Hanging a lot of configuration off an explicit Column entry
  • Assuming that scroll/overflow was vertical

The version my team wrote is internal, but a (very rough) open-source re-implementation is at https://github.com/jstclair/knockout-virtual-grid (hotkeys for editing the grid are documented at https://github.com/gnab/editableCell#list-of-keyboard-shortcuts )

Ability to reorder columns

I would really like to see this feature implemented, is it in any future plan?

I'm also trying to do this myself, but the way columns are handled internally currently transcend my poor React knowledge

Re-Renders when scrolling past the sides

Seems inefficient to call render when the scroll position hasn't actually changed, even though the user is 'scrolling'

I've tested this by returning new data from rowGetter func such that shouldComponentUpdate in FixedDataTableRow always returns false

visibleRows callback?

We've got a table view that loads data as it is fetched. Using rowGetter, we check if there is data. If there is none that index is queued for fetching. Once it reaches a certain size or after a certain debounce time, the missing indexes are fetched.

That solution is serviceable at best but not at all efficient. It's not efficient when scrolling up a row (since it doesn't know direction) and when re-fetching the table (such as sorting or changing query) there isn't an easy way to find the starting offset to fetch from. Unless...

We have a visibleRows callback. That way we know exactly what is seen as each row is fetched. 10...20 then 11...21, etc. It shows direction and lets us know the last visible rows to fetch when re-fetching.

tl;dr need way to know what rows are visible for smarter fetching of server data.

Table direction

Is it possible to have the table load upwards? E.g. imagine displaying a list of messages, the newest of which is at the bottom and you can scroll upwards to see (and potentially load) older messages.

Also, pardon my asking, but what is the state of this project? Are there still people working on it or is it "take it as it is"?

Can't get fixed data table to work

If I install from npm, I get #11 error.
If I install from github via npm install --save git+https://github.com/facebook/fixed-data-table, I get the following error: Error: Cannot find module './internal/FixedDataTableRoot' from '/Users/szhen2/Documents/app/node_modules/fixed-data-table'

I'm using the sample code provided in the homepage

Add/improve examples

Feel free to claim one of these task or provide suggestions for other examples we could add.

process is not defined.

I am using fixed-data-table v0.1.0 with react 0.12.2 and i get the following error in the browser

Uncaught ReferenceError: process is not defined18../ExecutionEnvironment @ FixedDataTableRoot.js:14s @ _prelude.js:1(anonymous function) @ _prelude.js:156../internal/FixedDataTableRoot @ main.js:1s @ _prelude.js:1(anonymous function) @ _prelude.js:14.fixed-data-table @ ratings.js:7s @ _prelude.js:1(anonymous function) @ _prelude.js:11../footer @ app.js:10s @ _prelude.js:1e @ _prelude.js:1(anonymous function) @ _prelude.js:1

Here is the react component, which uses the table, which is just code from the samples.

'use strict';

var React = require('react');
var {Table, Column} = require('fixed-data-table');

var rows = [
  ['a1', 'b1', 'c1'],
  ['a2', 'b2', 'c2'],
  ['a3', 'b3', 'c3']
];

var Ratings = React.create({
  getInitialState() {
    return {
      data: rows
    }
  },

  render: function() {
    return (
      <Table
        rowHeight={50}
        rowGetter={this.state.data}
        rowsCount={this.state.data.length}
        width={5000}
        height={5000}
        headerHeight={50}>
        <Column
          label="Col 1"
          width={3000}
          dataKey={0}
          />
        <Column
          label="Col 2"
          width={2000}
          dataKey={1}
          />
      </Table>
    );
  }
});

module.exports = Ratings;

and here is the usage

'use strict';

var React = require('react');
var Router = require('react-router');
var {DefaultRoute, Link, NotFoundRoute, Route, RouteHandler} = Router;
var {Panel} = require('react-bootstrap');

var Header = require('./header');
var Footer = require('./footer');
var Ratings = require('./ratings');

var App = React.createClass({
  getInitialState() {
    return {
    };
  },

  componentWillMount() {
  },

  componentWillUnmount() {
  },

  render() {
    return (
        <div>
          <Ratings />
        </div>
    );
  }
});

var NotFound = React.createClass({
  render() {
    return (
      <h2>Not found</h2>
    );
  }
});

var routes =
  <Route name="app" path="/" handler={App}>
    <DefaultRoute handler={NotFound}/>
    <NotFoundRoute handler={NotFound}/>
  </Route>;

Router.run(routes, function(Handler, state) {
  React.render(<Handler params={state.params} query={state.query}/>, document.getElementById('app'));
}

Any ideas?

Can't use flexGrow and resizable columns simultaneously

Seems like if you specify a flexGrow constant and isResizeable on the same column, it should respect the flexGrow constant until the column is resized for the first time. Right now it just causes columns not to resize properly.

Browser support information is missing

There doesn't seem to be any information listed on supported browsers. Is there any information available and if there is, is this something that could be added to the README?

Thanks!

Scrolling page once on the top/bottom of table

Usual behavior for scrollable divs is that if you reach top/bottom via mouse scroll is that page continue to scroll.. But fixed-data-table eat all the scroll events when mouse is on top of it even if top/bottom is reached.

Would be possible to add this behavior in fixed-data-table?

Middle click and scroll don't seem to work

Not sure if this is a planned feature or not, but it would be nice to be able to 'autoscroll' with middle-click and scroll as you would in a normal browser window. Right now it seems like that functionality is unavailable.

Scrolling doesnt work in Chrome or IE11 if you have a touch screen

Slightly strange one here - but seems to apply to any laptop with touchscreen but using an external mouse (quite common on win8 machines)
I've got a touchscreen laptop (Yoga pro 2, win 8.1) and in firefox scroll works fine (though framerate does seem a bit slow)

In chrome (44) and IE11 though, things get a bit weird..
In chrome, scroll on the table works with touch, but NOT with the mouse. I also cant see the scroll bar (appears on FF)
In IE11 scroll is bust completelly bust (touch tries to scroll the page, mouse wheel does nothing)

Becomes a bit of a bigger issue at work, with external monitors still apparently thinking they are touch screen..
Guess this relates to overriding the native browser scroll and #20 and possibly #15 ?
All happening on http://facebook.github.io/fixed-data-table/example-object-data.html

Adding onRowMouseLeave

Does it make sense to add onRowMouseLeave to the Table API? onRowMouseEnter is great, but I want to have a feature where the row changes when the mouse is over it, then reverts back when it leaves. Doing this with just :hover CSS properties might work, but I'm wondering if a JS handler is better.

Be more responsive-friendly?

Currently we have to pass the width of the table into the component on initial rendering, and the resulting table has a fixed width which does not response to window resizing etc. Is it possible to make the component more responsive without compromising the performance?

Table keeps showing old data after re-rendering as if the whole table has been cached

I'm using a pattern like this:

const [matrix, columns] = generateData(this.props.data);

return <Table width = {400}
              height = {500}
              headerHeight = {36}
              rowHeight = {36}
              rowGetter = {x => matrix[x]}
              rowsCount = {matrix.length}
              overflowX = "hidden">
         {columns.map((v, k) => (
           <Column width = {100}
                   label = {v}
                   dataKey = {k} />
         ))}
       </Table>

And inside generateData I'll do a switch-case basing on some other state so that whenever this state changes, the columns will update accordingly. However, what I was seeing is that under seemingly random occasions, the table will just re-render with its previous data, as if the whole table has been cached. No warnings or errors whatsoever.

Is there a way to re-render Column header?

hello!

I have a fixed data table, and am trying to add column sorting when a user clicks on a column header. I am using the headerRenderer property of Column to pass in a custom header rendering function. Within this function, I have an onClick handler on my header virtual element that tries to setState to re-render the view. However, the methods I passed into headerRenderer are not re-triggering.

Is there anyway for me to get the Column headers to re-render after a call to setState?

Thanks!

request: Simple, stand-alone examples with systematic size calculations

I had hoped to replace some simple data tables in my application with fixed-data-table but gave up after spending a few hours and having nothing visible on the page.

I spent some time studying the examples in this repo but had a difficult time distinguishing boilerplate or scaffolding related to the pages of this repo (things like the use of ExamplesWrapper, the direct inclusion of individual .css files from the src directory at the top level instead of the single css file recommended in the README, the use of non-React callbacks to track window size in ExamplesPage.js) from what's really needed to get data tables working.

I think it would be easier to get started using DataTables with a separate examples repository that built independently and had three individual example pages with (hopefully) a single, much smaller source file per example. That would also provide a baseline I could compare against when things aren't working in my app.

A secondary plea: Like the vast majority of users my tables are in a container

whose size is controlled by the grid of the framework I'm using (Bootstrap in my case). The ExamplesPage.js appears to compute tableWidth and tableHeight properties using global top level non-React callbacks that track window size and subtract fixed constants. Would be great to have an example that showed how to do these size calculations in some more systematic, modular and robust way for the common case.

TypeError: undefined in browser in Safari Version 8.0.3 (10600.3.18)

Simply adding:
...
var FixedDataTable = require('fixed-data-table');
...

Produces this error in the browser:

TypeError: undefined is not a function (evaluating 'Object.assign(destination, propertyObjects[i])')

.... package.json
...
"dependencies": {
"fixed-data-table": "^0.1.1",
"fluxxor": "^1.5.2",
"react": "~0.12.2",
"react-bootstrap": "^0.14.1",
"react-router": "^0.11.6",
"react-router-bootstrap": "^0.8.3"
},
...

However, it works great in Firefox 35.0.1

Pagination example

I would like to know how pagination was done using this component. any one has a sample code. thanks

Something like iOS tableView reloadRowsAtIndexPaths

When new data enters the state after initial render the table doesn't pick it up untill it needs to rerender the rows affected.

Would be nice to be able to somehow specify that rows should be rerendered.

Would also help with partial data in issue #28 .

using rowClassNameGetter() to use classes with different backgrounds

This was interesting. I use the rowClassNameGetter, which basically returns one of the following class names randomly for each row: [ 'red', 'green', 'yellow' ]

Then adding css style with background-color, as an example:

.red .public_fixedDataTableCell_main {
background-color: red;
}

Now try scrolling, warning for epileptics, it flickers/blinks and goes bananas, I suspect this has todo with your scrolling magic :). It does not happen if you simply change the colors of the standard highlighted/normal rows, it has something todo with the randomness, that some rows are color X but not others. Not sure if this is working as intended or if it should be considered a bug.

Anyway I suppose it would be useful to change colors of rows depending on some condition X.

cellRenderer (checkbox) in column does not re-render when using setState

I can use jquery to keep the state in the browser and that works just fine. However, I was looking for a react way and it seems I ran into a re-render issue in the fixed-data-table.
Is my thinking wrong?

See the original question here: http://stackoverflow.com/questions/29067247/check-all-boxes-in-a-fixed-data-table-by-using/29090399

'use strict';

var React = require('react/addons');
var Table = require('fixed-data-table').Table;
var Column = require('fixed-data-table').Column;

// Fixed data tables (Facebook) requirement:http://facebook.github.io/fixed-data-table/
require('../../styles/fixed-data-table.css');
var TableTester = React.createClass({
  getInitialState: function(){
    return ({
      selected:[],
      rows: [
        ['a1', 'b1', 'c1'],
        ['a2', 'b2', 'c2'],
        ['a3', 'b3', 'c3'],
      ]      
    })
  },
  render: function () {
    var data = this.state.rows;

    return (
      <div>
        <label>Check All</label>&nbsp;<input type="checkbox" onClick={this._checkall} />
        <Table rowsCount={data.length} rowGetter={this._rowGetter} width={1000} height={300} headerHeight={50} rowHeight={50}>
          <Column label="Col 1" width={500} dataKey={0} />                                                            
          <Column label="Col 2" width={500} dataKey={1} cellRenderer={this._renderCheckbox} align="center" />
        </Table>
      </div>
    );
  },

  _checkall:function(e){
    var newSet = [];
    if (e.target.checked) {
      this.state.rows.forEach(function(columns){
        newSet.push( columns[1] );
      });
    }
    this.setState({
      selected: newSet
    });

  },

  _onChange: function(e) {
    var {checked, value} = e.target;   
    var newSet = this.state.selected;
    if ( checked && newSet.indexOf(value) < 0 ) { // does not exist in list
      newSet.push(value);
    } else {
      newSet.splice(newSet.indexOf(value), 1);
    }  
    this.setState({
      selected: newSet
    });

  },  

  _renderCheckbox: function(data){
    var checked = this.state.selected.indexOf(data) >= 0; // value is in list  
    return <input type="checkbox" value={data} onChange={this._onChange} checked={checked} />;
  },

  _rowGetter: function(rowIndex){
      return this.state.rows[rowIndex];
  }

});

module.exports = TableTester;

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.