Comments (5)
See #103. I’m not sure I’m working towards the right solution here.
First, I added row and column props so the pivot can be rendered immediately with default columns and row. I will add filters and fix the fields appearing in the selectable fields and columns.
Secondly I added a onChange prop to the Pivot component.
If present the onChange function is executed in the Pivot componentWillReceiveProps and the normal componentWillReceiveProps resetting function is ignored.
componentWillReceiveProps(nextProps) {
if (nextProps.onChange !== undefined) {
const newState = this.props.onChange(this.state);
So the state of the pivot will be updated with the newState (data will be taken from nextProps however).
So you can pass the Pivot an onChange function like so:
onChange={ (prevState) => {
const newState = prevState;
newState.colFields =[“name","house"];
return newState
}}
The onChange function is called with the current state of the Pivot, passing it back to the parent component for modification, and then passes it back to the Pivot and updates the Pivot component with the next state.
With this function present, any change to the props will not call the normal componentWillReceiveProps function and allow new props such as onLeftHeaderCellClick, to be passed down without completely resetting the Pivot.
from react-virtualized-pivot.
I have checked it out and this branch provides me with the options that I need. So in my opinion you are going towards the right solution.
The table can now return it's state, allowing the user to manipulate or store the configurations. And the added rows and column props allows an initial structure of the Pivot to be passed. In the future you could even consider to allow more props to be passed which would allow for a completely pre-defined Pivot.
Thank you for your work. I will continue to follow the progress.
from react-virtualized-pivot.
@GerjonM It seems right now whenever the Pivot
componentWillReceiveProps
is triggered it will re-render with the props it is passed and this essentially wipes out / resets the current pivot (aside from a change in the colorPack
props which it handles and doesn't wipe out / reset the current pivot).
Are you doing a onGridCellClick
and to trigger the modal? Then it doesn't sound like you aren't changing any props but it sounds like it still triggering the Pivot
componentWillReceiveProps
which wipes out / resets the current pivot.
Regardless of what you are doing exactly... I agree, the pivot shouldn't be wiped out if none of the props change. And if you change one of the Pivot
props you should be shown the same pivot you were looking at before (or it should re-render according to the previous props plus the change). I like your idea of the onChange
prop that gets a representation of the state and a way to pass this state back in again as a prop. I will work on a PR and see what you @GerjonM and @pat310 think.
from react-virtualized-pivot.
@GerjonM Thank you for the feedback. I added filters as an additional prop to be passed to the Pivot component. I think pivots are now completely pre-definable. I've also finished having the table being able to return state. I just need to clean it up, and write some notes about the new features. I also have an issue where if you have rendered a pivot with a pivotOnChangeFunction defined, then change some props i.e. the data, with a different pivotOnChangeFunction, it will run the pivotOnChangeFunction based on the previous state of the old pivot... You can see this by switching from small dataset (initial demo render) to medium dataset (no pivotOnChangeFunction defined) then switch back to small dataset (pivotOnChangeFunction defined). I'll have to think about that a bit more but should finish this feature this weekend. If you have a chance to check it out again let me know!
from react-virtualized-pivot.
The pivotOnChangeFunction
does not (yet) update all of the props when changing, this causes some of the state of the previous dataset to contaminate the new one. This can become tedious with lots of data sets which all have its own initial state. I don't think it is unreasonable to reset the complete state when changing to a completely different dataset. And if the user wants some pre-defined state, he or she can pass that to the pivot.
For me, the functionality I was looking for is now present. I can play around with a pivot and save the state. And when I re-render (or change dataset), I can inject my configuration into the pivot from wherever I stored it or start with a blank slate if I have no stored configuration. Thanks a lot :)
from react-virtualized-pivot.
Related Issues (20)
- Row & Column Totals HOT 7
- Multiple Measures? HOT 4
- Add CSV/TSV Format Checker To Demo HOT 5
- TypeError: r.props.data[0].map is not a function HOT 3
- Check to see if importing css stylesheet is necessary
- Add auto-prefixed to support internet explorer
- Setting wheel hover circle not circular
- Double column field pivot does not display drilldown option
- Filter box should be taller and centered
- Fix react warnings HOT 1
- Fix menu dropdown z-index
- Add es6 build
- Update README
- Make header background the same as main background color
- Change color of white loader with standard colors
- Fix mobile arrows icon
- Put all css in react-virtualized-pivot specific classes
- Speed up pivot by reducing divs rendered
- Add commonjs option 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-virtualized-pivot.