[英]AutoCompleteEditor(react-data-grid) not working in chrome
[英]react-data-grid setScrollLeft is not a function - fixed columns not working - custom row renderer
我正在嘗試在react-data-grid中實現固定列。 我通過添加locked: true
跟隨這個例子 ,但它不起作用,所以我也嘗試使用自定義的渲染行,就像另一個例子一樣 。
我得到_this.refs[i].setScrollLeft is not a function
錯誤。 嘗試對同一個問題進行hacky評論對我來說也不起作用(抱歉沒有代表評論!)。
我也嘗試創建一個自定義的單元格渲染類 ,但仍然沒有運氣。 我也嘗試使用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>);
}
};
任何幫助深表感謝!
編輯:嘗試很多東西,仍然沒有運氣,但我已經發現setScrollLeft
方法永遠不會傳遞給Row
組件,所以也許它確實是refs和/或props傳遞的問題。
我不是100%確定“固定”列的含義,但是如果您希望列的大小由軟件設置而不是由用戶更改,則可以簡單地設置resizable = false。 在列上設置locked = true會產生“凍結”列的效果,這樣當您滾動時,特定列會保留在那里,這可能不是您想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.