EasyUI Forum

General Category => EasyUI for React => Topic started by: chrwei on December 13, 2019, 09:57:07 AM



Title: DataGrid initial selection, scroll into view
Post by: chrwei on December 13, 2019, 09:57:07 AM
I have DataGrid with the selection property selecting a row on load, but the selected row is not in view, any way to make it scroll itself into view? the jquery version seems to do this automatically, at least in one place I'm using it.


Title: Re: DataGrid initial selection, scroll into view
Post by: jarry on December 17, 2019, 12:54:59 AM
Please call 'scrollTo' method to scroll the specified row to the view.
Code:
componentDidMount(){
    const row = this.state.data[8]; // the row to scroll to
    this.setState({selection:row}, ()=>{
        this.dg.scrollTo(row)
    })
}
...
<DataGrid
    style={{ height: 250 }}
    ref={ref=>this.dg=ref}
    data={this.state.data}
    selectionMode="single"
    selection={this.state.selection}
    onSelectionChange={selection=>this.setState({selection})}
>
...


Title: Re: DataGrid initial selection, scroll into view
Post by: chrwei on December 19, 2019, 01:19:17 PM
that worked, thanks.