Comments (15)
I also like the idea of being able to set the selection as a property. It's handy that the component manages selection for you, but sometimes it would be nice to control that externally (for example, to restore the last selection from a previous editing session).
from react-datasheet.
@patrick-jones @nadbm
Maybe it should be optional. If the selected
prop is set the selection is controlled, otherwise we keep start
and end
in the state.
I could work on that when I have some time.
from react-datasheet.
🎉 I've made an implementation here: #74
from react-datasheet.
Closing this issue after @educastellano's PR
from react-datasheet.
@educastellano
I realized I forgot to document this. Can you try the prop "onSelect" to see if it does the trick?
Like the following:
onSelected(selected) {
this.setState({ selected })
}
<DataSheet
...
onSelect={onSelected}
/>
The onSelect, takes a function with the selected cell as a parameter (cell) => {}
. It only gets called if you click a new cell.
from react-datasheet.
The onSelect
prop works, but when I set the cell to the state, the selection disappears from the component, probably for the same reason that disappears when you click outside. I can try to look at the code later to see why that happens... But I think this prop could work for me! 👍
from react-datasheet.
@educastellano can you make a fiddle with the issue? The selection should not disappear on a state change.
from react-datasheet.
I managed to make a fiddle: https://jsfiddle.net/69z2wepo/99781/ I had some problems importing the library so I ended up including all the files in the JS section - seems to not be any collision with variable names. The example code is at the end.
The problem is happening when I pass a custom cell in the cellRenderer
prop. If I remove this prop it works correctly.
from react-datasheet.
Have a look at the changes I made here: https://jsfiddle.net/j7y0ga47/. You want to avoid using arrow functions as properties (more background here).
from react-datasheet.
As @patrick-jones mentioned, you want to avoid the arrow functions. His fiddle seems to be the same as above. Here is one without the arrow functions and bindings in the render function: https://jsfiddle.net/j7y0ga47/2/
from react-datasheet.
@patrick-jones @nadbm Perfect!! Thanks! 😃
The other problem I had is that I lose the selection when click outside the component, which I have fixed here: #63 Let me know what you think.
from react-datasheet.
Bah! I must have forgotten to save the changes to the fiddle.
from react-datasheet.
@patrick-jones no problem! 😃
Another thing, I'll probably need the selection of all the cells in case of selecting more than one. What about:
onSelected(selected, start, end) {}
selected
would still be a single cell or the last cell selected.
from react-datasheet.
@educastellano that sounds good. Currently, the onSelect method wasn't documented. So feel free to make a pull request against that.
from react-datasheet.
@educastellano agree about it being optional
from react-datasheet.
Related Issues (20)
- Callback while typing
- onCellsChange doesn't re-render changed cells HOT 1
- isCellNavigable is ignored when holding shift
- [Question]can react-datasheet work with Redux? HOT 1
- [Question] validate user's input when using react-datasheet as data input form HOT 1
- When I copy and paste from MS excel I am not getting exact value HOT 3
- Excel like Freeze Column HOT 1
- [Question] How to handle onDoubleClick for each cell? HOT 1
- Are types for default renderers, cell etc. missing?
- How to (programmatically) select all cells, then copy?
- feature request: influence enter key handling
- Allow Tab key in order to go out from the DataSheet to focus other DOM elements
- Bug: Copy and paste from MS Excel on a Windows machine pastes an extra empty cell HOT 1
- How do I initialize a datasheet with empty columns and rows which fills up my container? HOT 1
- What to use instead of deprecated `onPaste` function HOT 1
- Feature Request: Export as Excel/CSV HOT 2
- Does CTRL+Z word for undoing a paste? HOT 1
- Where can I see the code examples that are on the website? HOT 2
- Paste more rows than that is defined by the `grid`. HOT 2
- Deleting rows with Action Button HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-datasheet.