Giter Club home page Giter Club logo

Comments (7)

kriszyp avatar kriszyp commented on September 27, 2024

The point of mayHaveChildren is to be able to quickly and synchronously determine which nodes might have children with requiring a full asynchronous request/operation for their children. What is the use case for needing an asynchronous mayHaveChildren?

from dgrid.

ozdev avatar ozdev commented on September 27, 2024

In cases where asynchronous requests for children can be done locally (by using IndexedDB for example) and/or are cheap enough, an asynchronous mayHaveChildren frees you from having to create a property like 'childrenCount' or load all the data and cache them beforehand just to prevent expando icons from showing up next to nodes with no children.

from dgrid.

kfranqueiro avatar kfranqueiro commented on September 27, 2024

On the other hand, you also have to realize that mayHaveChildren is called for every cell in the tree column, which means you could easily be issuing upwards of 20 calls at once. Moreover, when the user actually does expand the child, that will then issue its own request. Asynchronous mayHaveChildren doesn't seem advisable, compared to the pattern of simply including a tiny bit of metadata with each item in the query result itself. (Moreover, I wouldn't want to entice people to toss an entire server request in there, which would be rather terrible.)

It also may be worth pointing out that the mayHaveChildren concept originated with dijit/Tree models, which only support synchronous implementations of the method.

from dgrid.

ozdev avatar ozdev commented on September 27, 2024

This old ticket well describes the problem I want to solve by asynchronous mayHaveChildren. Sometimes it's simply impossible to know whether a given node has children or not until actually requesting for it. So, I think, supporting both synchronous and asynchronous mayHaveChildren at least gives developers a choice whether to solve that 'empty folder' problem at all costs or just live with that.

Well, that's all I can say on this. So, feel free to close this issue if others think there is no need to discuss further.

from dgrid.

mikerobi avatar mikerobi commented on September 27, 2024

The point of mayHaveChildren is to be able to quickly and synchronously determine ...

Shouldn't the point be "to quickly determine?" Asynchronously does not automatically mean slowly. Shouldn't that determination be up to the developer?

I propose a compromise:

Add a prefetch property to the store. If it is true, mayHaveChildren is not called. Instead, expanding a row causes getChildren to be called for each child.

prefetch makes it pretty clear that you are doing something that could add significant overhead.

from dgrid.

 avatar commented on September 27, 2024

@mikerobi, I may be misreading your suggestion, I'm kind of confused as to how what you're suggesting is a compromise. Expanding a row is already what causes getChildren to be called; mayHaveChildren is simply called up-front to check whether an expando should even be displayed whatsoever for each row. If no mayHaveChildren method is defined on the store, every row will have an expando unconditionally.

If you're suggesting to call getChildren recursively on all children the moment a root-level row is opened, I'm not really sure how that solves the OP's problem, and I'd be rather reluctant to go that route. (Incidentally, the shouldExpand logic in #172 should allow for that if people are bent on it.)

from dgrid.

kfranqueiro avatar kfranqueiro commented on September 27, 2024

mayHaveChildren is still intended to be a synchronous API even in dstore. Given that, it doesn't make much sense to add complexity to dgrid for an unintended use of the API. (Again, if you omit mayHaveChildren entirely, you will just end up seeing expand icons on every row.)

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.