Comments (4)
One solution to that is to pad the number with zeroes, but another is to translate the number to base 36 like Drupal and at least one Django add-on does.
I think there is one more problem the base 36 encoding of ancestry does not solve and that is the issue of limit boundaries hitting an ancestry. Hopefully an example will illustrate this.
id: 105, Ancestry: Null
id: 117, Ancestry: 105
id: 118, Ancestry: 105/117
id: 119, Ancestry: 105/117/118
A LIMIT 0,3 (for the sake of the example above) would return the first three records, which will render correctly. The subsequent LIMIT 3,3 will return id: 119 which will not render correctly as its parents are not present.
I'm starting to think that pagination can only happen via two queries: the first paginates the roots; the second returns any children based on parents in the first query. The second query won't be pretty in that there will be a lot of (ancestry like '105%') or (ancestry like '109%') or (ancestry like '115%') and so on.
More thoughts are very welcome....
from ancestry.
I managed to come up with the following solution.
from ancestry.
There is also an issue with i18n - in some cases punctuation is ignored. so sorting 12/3/4 and 1/2/3/4 both are treated as 12345
Nice solution.
In it's current state, I don't feel this is doable.
Are you still hoping to get a change in master?
Over the years, have you found a good trade off to simplify this problem?
from ancestry.
I updated the SO article and will add to the wiki.
I'm hoping to come up with better solutions, but at least have one for now. (only took 10 years to find a solution that was not "paginate roots, then add all their children)"
from ancestry.
Related Issues (20)
- anyone could give clarity to the readme? HOT 6
- Multiple root nodes HOT 1
- gui or gem for generic tree editing? HOT 3
- Make it easier to change the serialization format for the ancestry column HOT 11
- Do I still need to write an arrange_as_array routine to get a children inclusive ordered list? HOT 6
- release next version HOT 6
- having trouble displaying tree in select across different models/controllers
- How do i create a nested ancestry drop down collection_select list for rails forms? HOT 1
- [Idea] Remove InstanceMethods mixin HOT 4
- arrange_as_array causing unknown error HOT 7
- no definition for arrange in arrange_as_array HOT 5
- Falseful changelog, incorrect README and broken code in 4.3.0 HOT 23
- ancestor_ids_in_database removed? HOT 2
- Error in MaterializedPath2 descendants SQL? HOT 6
- Configuring Ancestry to use UUID keys HOT 4
- path_ids_in_database removed? HOT 5
- virtual depth_cache HOT 4
- Why is there no leafs method? HOT 1
- STI breaks arrange scoping HOT 3
- add support for virtual parent_id and root_id
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 ancestry.