React-data-grid: how can i manual selected(focus) any cell with event?

Created on 9 Jan 2019  路  7Comments  路  Source: adazzle/react-data-grid

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.

Question

Most helpful comment

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

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

All 7 comments

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

Waiting for the solution

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

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

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

..
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();

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

..
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 :(

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

..
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?

documentation leaves much to be desired, ahem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JordanBonitatis picture JordanBonitatis  路  4Comments

markmus picture markmus  路  4Comments

anil1712 picture anil1712  路  4Comments

daniel1943 picture daniel1943  路  3Comments

jlarso11 picture jlarso11  路  3Comments