react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

how can i manual selected(focus) any cell with event?

Open flyingcrp opened this issue 7 years ago • 7 comments

i wanto focus some cell when the grid is mounted. i search some issue and try ,like this #552. operate the DOM with js event,,but its not work . so,this coming. my 'lovely' pm want to autofocus anyone cell with logical condition . so,what should I do? thanks guys.

flyingcrp avatar Jan 09 '19 11:01 flyingcrp

i try this #1151 . it's not work.

flyingcrp avatar Jan 09 '19 12:01 flyingcrp

Waiting for the solution

flyingcrp avatar Jan 14 '19 04:01 flyingcrp

Try this: someEvent = event => { const idx = 3; const rowIdx = 3; this.grid.selectCell({ idx, rowIdx }) };

<ReactDataGrid .. ref={grid => this.grid = grid} .. />

Mishqq avatar Feb 06 '19 13:02 Mishqq

Try this: someEvent = event => { const idx = 3; const rowIdx = 3; this.grid.selectCell({ idx, rowIdx }) };

<ReactDataGrid .. ref={grid => this.grid = grid} .. />

thanks god!! it's work. But it should be with event.

eg:

<a
                        className={'toFocus'}
                        style={{
                            position: 'fixed',
                            left: 20000,
                            top: 20000,
                        }}
                        onClick={() => {
                            const idx = 1;
                            const rowIdx = 0;
                            this.grid.selectCell({idx, rowIdx});
                        }}
                    >
                        U CAN NOT SEE ME 
                    </a>

....
js: whereever u want to focus some cell , just trigger the event

document.getElementsByClassName('toFocus')[0].click();

flyingcrp avatar Feb 11 '19 04:02 flyingcrp

Try this: someEvent = event => { const idx = 3; const rowIdx = 3; this.grid.selectCell({ idx, rowIdx }) };

<ReactDataGrid .. ref={grid => this.grid = grid} .. />

Thanks! This method works as expected. I'm only wondering why it does not have any single mention in documentation :(

steamhammer avatar Mar 11 '19 19:03 steamhammer

Try this: someEvent = event => { const idx = 3; const rowIdx = 3; this.grid.selectCell({ idx, rowIdx }) };

<ReactDataGrid .. ref={grid => this.grid = grid} .. />

This works for single cell selection.Is there a way to select multiple cells like range of selection from topLeft to bottomRight positions?

Tarun-1994-Kumar avatar Jan 22 '20 07:01 Tarun-1994-Kumar

documentation leaves much to be desired, ahem

avalanche1 avatar Jun 26 '20 23:06 avalanche1