Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Infinite scrolling with remote data available? #221

Open
doranen opened this issue Sep 24, 2014 · 76 comments
Open

Infinite scrolling with remote data available? #221

doranen opened this issue Sep 24, 2014 · 76 comments

Comments

@doranen
Copy link

doranen commented Sep 24, 2014

Don't see a way to provide the data necessary to enable infinite scrolling using query

@dimirc
Copy link
Contributor

dimirc commented Oct 10, 2014

Can you elaborate more on this?

@doranen
Copy link
Author

doranen commented Oct 10, 2014

from the select2 docs:
Infinite Scroll with Remote Data
Select2 supports lazy-appending of results when the result list is scrolled to the end. In order to enable the remote service must support some sort of a paging mechanism and the query function given to Select2 must take advantage of it. The following example demonstrates how this can be set up. Search for some keyword and then scroll the result list to the end to see more results load:

The deprecated version of this angular-select2 plugin allows it

@mtraynham
Copy link

+1
The deprecated angular-ui-select2 component has the query function, which would be triggered by either a change in search text or by scrolling to the end of the choices container (if the previous results indicated more: true). My usecase is a bit different though, as I used it for performance reasons. I already had the data client side, but 1000+ DOM elements for choices was a burden.

Here's an example of how I used the query function to page values ($scope.values) into the DOM:

    $scope.select2Options = {
        query : function (query) {
            var data = {results: [], more: false};
            // Reduce all values to what's needed
            if ($scope.values) {
                // Filter search
                data.results = $scope.values.reduce(function (previous, current) {
                    if (query.matcher(query.term, current.text)) {
                        previous.push(current);
                    }
                    return previous;
                }, []);
                // Page
                if (data.results.length > query.page * $scope.limit) {
                    data.more = true;
                }
                data.results = data.results.splice((query.page - 1) * $scope.limit, $scope.limit);
            }
            query.callback(data);
        },
        multiple: true
    };
<input type='hidden' ui-select2='select2Options' ng-model='filters'/>

Granted, another solution in my case, is just don't render all the options at the same time...

@Condor2708
Copy link

+1 ... It is a great characteristic of the select2 component

@MikeABentley
Copy link

+1 I need to use the select2 component to leverage the remote data functionality in my angular based application

@masscrx
Copy link

masscrx commented Nov 7, 2014

+2

@MikeABentley
Copy link

Ended up rolling my own directive using the select2 control. My primary need was the remote data. Perhaps I'll swap in this control when remote data is supported.

@Wangor
Copy link

Wangor commented Dec 2, 2014

+1

6 similar comments
@klmdb
Copy link

klmdb commented Dec 9, 2014

+1

@kiwipiet
Copy link

kiwipiet commented Jan 4, 2015

+1

@ephraimm
Copy link

ephraimm commented Jan 5, 2015

+1

@MattShrider
Copy link

+1

@yusin
Copy link

yusin commented Jan 8, 2015

+1

@NielsGregers
Copy link

+1

@asm0dey
Copy link

asm0dey commented Jan 24, 2015

👍

Waiting for this to be implemented - unable to migrate.

@jpmckearin
Copy link

+1

@tushar-borole
Copy link

+1

8 similar comments
@arjundas
Copy link

+1

@PavelKonon
Copy link

+1

@Xepe
Copy link

Xepe commented Mar 5, 2015

👍

@gouxlord
Copy link

gouxlord commented Mar 5, 2015

+1

@radyz
Copy link

radyz commented Mar 5, 2015

+1

@simkessy
Copy link

simkessy commented Mar 5, 2015

+1

@zsapkagy
Copy link

zsapkagy commented Mar 6, 2015

👍

@tadchristiansen
Copy link

+1

@soichih
Copy link

soichih commented Oct 1, 2015

+1

3 similar comments
@alexcreasy
Copy link

+1

@dolzenko
Copy link

👍

@ivan206
Copy link

ivan206 commented Oct 26, 2015

+1

@mpochron
Copy link

-(-1)

@fynnfeldpausch
Copy link

+1

@daric81
Copy link

daric81 commented Nov 26, 2015

+1

We use the deprecated ui-select2 and cant migrate without this feature

@pliashkou
Copy link

+1

@betonetotbo
Copy link

Hi guys!

I was in the same trouble, i solved using this:

https://jsfiddle.net/betonetotbo/0yfhe7pf/

@doubaokun
Copy link

+1

@lky1001
Copy link

lky1001 commented Mar 26, 2016

@betonetotbo very good solution for me! thanks

@wufangjian
Copy link

+1

3 similar comments
@felipexw
Copy link

+1

@unrealsolver
Copy link

👍

@arjundas
Copy link

arjundas commented Aug 5, 2016

👍

@sfreeland
Copy link

Pretty please?

@jacek213
Copy link

+1

2 similar comments
@pencilcheck
Copy link

+1

@robsonrosa
Copy link

+1

@pencilcheck
Copy link

An example using ui-select-infinity plugin: http://plnkr.co/edit/p6Dt3yvTq40Vn56AKiqC?p=preview

I think it can be simplified if it is merged with ui-scroll. Which i'm going to try soon.

@jacek213
Copy link

jacek213 commented Oct 4, 2016

Yesterday I've also introduced ui-select-infinity into my app. It works fine except sometimes it throws Cannot read property 'getBoundingClientRect' of undefined exception. If someone encounters the same problem - check my fork which solves it: hyzhak/ui-select-infinity#11

@sjahongir
Copy link

Great! +1

@akaash2512
Copy link

I am using ui-select2 dropdown with infinite scroll But search feature is not working with it. Can anyone please help ?

@cppmyjob
Copy link

+1

@Condor2708
Copy link

Any state of situación for this request? Is there any documentación how ti solve this?

@dmarafetti
Copy link

+1

3 similar comments
@jamespsterling
Copy link

+1

@Roycohen
Copy link

Roycohen commented Oct 9, 2017

+1

@condereis
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests