Griddle icon indicating copy to clipboard operation
Griddle copied to clipboard

InfiniteScrolling in 1.0

Open ZachStoltz opened this issue 9 years ago • 18 comments

Hello Griddle Team! Congrats on releasing 1.0. Looking forward to using it.

Trying to migrate from 0.7.1 to 1.0 due to not being able to toggle column visibility out of the box and decided to just take the dive into 1.0.

Does Griddle still support Infinite Scrolling by setting a prop on the Griddle component, or is it possible now to integrate in a library like react-virtualized to handle rendering the RowDefinition components needed for Griddle?

Thanks!

ZachStoltz avatar Feb 22 '17 17:02 ZachStoltz

Thanks so much -- we're excited to have it released. If you're successfully using 0.7.1 I would wait a bit until we have the official upgrade guide complete. @joellanciaux is kind of taking point on that one but it likely won't be too far off. That said, with the architecture changes, some of the plugins are not baked in to core Griddle and will be coming shortly there-after as plugins (namely subgrid and selection).

I would imagine someone could write a plugin for react-virtualized (and that would be really really cool to see), although the ability to have a pipeline of plugins may be lost depending on how the other plugins interact with the view components (it may not too -- I'd have to look more into how that could work).

Additionally, we have a plugin that does virtual scrolling that will be receiving some updates and performance fixes in the weeks to come that can be used as follows:

import Griddle, { plugins } from 'griddle-react'
...
<Griddle data={someData} plugins={[..., plugins.PositionPlugin({tableHeight: 600 }) />

https://github.com/GriddleGriddle/Griddle/blob/2988f42dd4b3db027587694028783f6507e7848d/stories/index.js#L258-L267 for more info on this. Please let us know if this helps :+1:

ryanlanciaux avatar Feb 22 '17 19:02 ryanlanciaux

ahh nice! That is what I am looking for.
Only place I didn't look to see about the virtual scrolling was in the stories dir! :smile:

Thanks for the speedy response!

ZachStoltz avatar Feb 22 '17 19:02 ZachStoltz

@ryanlanciaux is Infinite scroll already in Griddle? If yes, could you give me an example how to implement it.

vozni4iy avatar Mar 30 '17 09:03 vozni4iy

Is there an example of how the infinite scroll works for Griddle 1.0 and above? The link for https://github.com/GriddleGriddle/Griddle/blob/master/stories/index.js#L260 it's broken now

jrmartin avatar Aug 01 '17 15:08 jrmartin

@jrmartin Is there an example of how the infinite scroll works for Griddle 1.0 and above?

https://github.com/GriddleGriddle/Griddle/blob/2988f42dd4b3db027587694028783f6507e7848d/stories/index.js#L258-L267

dahlbyk avatar Feb 09 '18 06:02 dahlbyk

can we call the API service to get more data on scroll, what I mean i will load first 100 records and on each scroll will call the API to get the next 50 records(101-150) and append to the grid, is there any way to do this.

sansetty2510 avatar Mar 29 '18 13:03 sansetty2510

can we call the API service to get more data on scroll, what I mean i will load first 100 records and on each scroll will call the API to get the next 50 records(101-150) and append to the grid, is there any way to do this.

That's not currently supported; PositionPlugin unfortunately depends on LocalPlugin. There's some discussion happening over here, if you want to help implement something: https://github.com/GriddleGriddle/Griddle/issues/795#issuecomment-373708306.

dahlbyk avatar Mar 29 '18 18:03 dahlbyk

Is there any way to get the onscroll event handler in the griddle

sansetty2510 avatar Mar 30 '18 06:03 sansetty2510

Not without patching PositionPlugin, though adding a callback to its options should be pretty easy.

dahlbyk avatar Mar 30 '18 18:03 dahlbyk

@dahlbyk is there any way to create our own custom plugin?

sansetty2510 avatar Apr 04 '18 11:04 sansetty2510

@dahlbyk is there any way to create our own custom plugin?

Absolutely. A plugin is just an object that includes one or more of the following:

  • components: an object that includes new or replacement components
  • events: callbacks for pagination/sorting/filtering (not particularly well defined)
  • reducer: object with reducer functions (keyed by action name)
  • selectors: data selectors from state to get props for components (used with Reselect)
  • settingsComponentObjects: object to customize settings components
  • styleConfig: object to customize icons, classNames and styles
  • initialState: values to merge into the initial internal state
  • listeners: internal Redux store listeners
  • reduxMiddleware: middleware for the internal Redux store

"Patching" PositionPlugin could be as simple as calling the exported plugins.PositionPlugin function and then overriding selectors and maybe a few components with your modifications.

dahlbyk avatar Apr 04 '18 19:04 dahlbyk

@dahlbyk thank you very much for update :)

sansetty2510 avatar Apr 05 '18 07:04 sansetty2510

@dahlbyk i am creating a custom plugin, i have some requirement to pass some parameter for my custom plugin is there any way to pass the parameter for custom plugins?

sansetty2510 avatar Apr 05 '18 13:04 sansetty2510

@sansetty2510 that's how the PositionPlugin works: we export a constructor function that accepts plugin config, and that function returns the plugin object used by Griddle:

<Griddle data={...} plugins={[PositionPlugin({ config goes here })]) />

dahlbyk avatar Apr 05 '18 14:04 dahlbyk

@dahlbyk how to access that 'config' parameter in my custom plugin, for example i am using components->Layout the layout component i am enhancing, i want to access that 'config' parameter in my Layout class. How to do it. I just created a function that can access the 'config' data, but i am unable to pass it for my layout component.

sansetty2510 avatar Apr 06 '18 09:04 sansetty2510

I would mimic how PositionPlugin handles config: it merges the values into initialState.positionSettings and uses selectors to make the values available to components in TableEnhancer. You would use a similar technique with a LayoutEnhancer.

dahlbyk avatar Apr 06 '18 20:04 dahlbyk

@dahlbyk I have implemented the infinite scroll by calling the services based on the user actions by creating the custom plugin, but I am facing one issue like the screen is getting flickering on some position of scroll, I debug the issue I came to know that if we are using 'PositionPlugin' in the 'tbody' by default one row(tr) is getting created and on each scroll the height of that 'tr' is changing in some position of scroll bar the value is keeping on updating and not stooping by this reason screen is getting flickering... please suggest me how to fix this issue.

sansetty2510 avatar May 03 '18 09:05 sansetty2510

(Comment moved to https://github.com/GriddleGriddle/Griddle/issues/814#issuecomment-386295655)

dahlbyk avatar May 03 '18 13:05 dahlbyk