3

这里有固定数据表示例:

https://github.com/facebook/fixed-data-table/blob/master/examples/FilterExample.js

但我很难理解这一点。

我用 ES5 写了一些关于固定数据表的代码。现在我想在我的代码中添加“过滤”示例。但是示例是 ES6。

你能帮我理解或如何将 ES6 转换为 ES5。

这是我的代码:

var rows = [{"id":1,"first_name":"William","last_name":"Elliott","email":"welliott0@wisc.edu",
"country":"Argentina","ip_address":"247.180.226.89"},
{"id":2,"first_name":"Carl","last_name":"Ross","email":"cross1@mlb.com",
"country":"South Africa","ip_address":"27.146.70.36"},
{"id":3,"first_name":"Jeremy","last_name":"Scott","email":"jscott2@cbsnews.com",
"country":"Colombia","ip_address":"103.52.74.225"},

// more data
];

ReactDOM.render(
    <Table
      height={rows.length * 30}
      width={1150}
      rowsCount={rows.length}
      rowHeight={30}
      headerHeight={30}
      rowGetter={function(rowIndex) {return rows[rowIndex]; }}>

      <Column dataKey="id" width={50} label="Id" />
      <Column dataKey="first_name" width={200} label="First Name" />
      <Column  dataKey="last_name" width={200} label="Last Name" />
      <Column  dataKey="email" width={400} label="e-mail" />
      <Column  dataKey="country" width={300} label="Country" />

    </Table>,
    document.getElementById('root')
);
4

1 回答 1

2

您可以使用React.createClass. 这是一个例子:

var FilterExample = React.createClass({
  // constructor
  getInitialState: function() {
    this._dataList = new FakeObjectDataListStore(2000);    
    this._onFilterChange = this._onFilterChange.bind(this);
    return {
      filteredDataList: this._dataList,
    };
  },
  ...
  render: function() {
    <Table
    ...
    </Table>,
    document.getElementById('root')
  }
});
于 2016-01-11T19:40:38.233 回答