固定列を私のreact-data-gridに実装しようとしています。 exampleの後にlocked: true
を追加しても動作しませんので、other exampleのようにレンダリングされたカスタム行を使用しようとします。反応データグリッドsetScrollLeftは関数ではありません - 固定列が動作しない - カスタム行レンダラー
_this.refs[i].setScrollLeft is not a function
エラーが発生します。 this same questionのハッキーなコメントを試しても私にとってはうまくいきません。
私もcreate a custom cell render classにしようとしましたが、まだ運がありません。 私はまた、代わりにコールバック方法をrefs
使用しよう:
class CellRenderer extends React.Component {
render() {
return <ReactDataGrid.Cell {...this.props}/>
}
};
class RowRenderer extends React.Component {
static propTypes = {
idx: React.PropTypes.string.isRequired
};
setScrollLeft = (scrollBy) => {
// if you want freeze columns to work, you need to make sure you implement this as apass through
this.row.setScrollLeft(scrollBy);
};
getRowStyle =() => {
return {
color: this.getRowBackground()
};
};
getRowBackground =() => {
return this.props.idx % 2 ? 'green' : 'blue';
};
render() {return (<div style={this.getRowStyle()}>
<ReactDataGrid.Row
{...this.props}
ref={r => { this.row = r; }}
cellRenderer={CellRenderer}
/>
</div>);
}
};
をすべてのヘルプははるかに高く評価されます!
EDIT:多くのことを試してもまだ運はありませんが、setScrollLeft
メソッドがコンポーネントに渡されることはありません。したがって、おそらくrefsやpropsに問題があるかもしれません。
コールバックに設定する前にrefに与えた名前は何ですか? –
申し訳ありませんが、私はその質問を理解していません。 'RowRenderer'はステートフルなコンプネントなので、' ref = {r => {this.row = r; }} '十分であるので、私は' this.row.setScrollLeft(scrollBy); 'を呼び出すことができます、そうではありませんか? – gkri