Coder Social home page Coder Social logo

Option to render trees expanded about dgrid HOT 9 CLOSED

sitepen avatar sitepen commented on August 15, 2024
Option to render trees expanded

from dgrid.

Comments (9)

mikerobi avatar mikerobi commented on August 15, 2024

I would prefer passing an expandIf function to the column plugin. If the function returns true for a row, the node and and all of its ancestors are rendered expanded.

from dgrid.

zernyu avatar zernyu commented on August 15, 2024

+1

That's a much better idea.

from dgrid.

mikerobi avatar mikerobi commented on August 15, 2024

I realize that in my first comment, I had things backwards. expandIf will only be called when a row is inserted, thus its ancestors have already been expanded.

Determining the depth of a node from within the expandIf function could still require walking up the tree to count nodes. I suggest that it receives the depth as its second argument.

from dgrid.

zernyu avatar zernyu commented on August 15, 2024

Or the nodes can have a depth property that the expandIf function can check.

from dgrid.

mikerobi avatar mikerobi commented on August 15, 2024

If you are using lazy loading, there may be situations where the depth of a record is unknown unless you walk up the tree.

from dgrid.

zernyu avatar zernyu commented on August 15, 2024

Doh. I'm an idiot ;)

from dgrid.

 avatar commented on August 15, 2024

I've taken a stab at this with #172. Open to comments for the time being.

Thanks @mikerobi for the idea of conditionalizing it. Initially I was very reluctant to entertain the idea of blanket auto-expand, just because I don't like tempting people to use it without considering the consequences (especially if it's being used with a non-memory store, i.e. going back to the server for each request for children).

However, it is a request that comes up fairly often, and this also gave me the opportunity to also allow "preserving" of expanded states when rows get unrendered and re-rendered later (either from scrolling or observer-induced remove/insert operations).

from dgrid.

zernyu avatar zernyu commented on August 15, 2024

Awesome, I will test this out now. I've been running into more and more problems with reexpanding trees after refreshing them.

from dgrid.

 avatar commented on August 15, 2024

Closing this now, since #172 has been merged. Thanks @swiftdemise for the additional feedback and tire-kicking.

from dgrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.