EasyUI Forum
May 05, 2024, 09:33:42 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: DataGrid initial selection, scroll into view  (Read 5379 times)
chrwei
Full Member
***
Posts: 219


View Profile Email
« 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.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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})}
>
...
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #2 on: December 19, 2019, 01:19:17 PM »

that worked, thanks.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!