How to load multiple records into a Combo?

Asked

Viewed 131 times

0

I need to create a functionality for a system that one can select multiple records in a Combo, but the problem is that I am loading over 5000 records and the browser is crashing.

Is there any way to create this without crashing? Type an autocomplete with the possibility to select multiple records?

The information is coming from a JSON.

Example of what I’m using:

inserir a descrição da imagem aqui

  • I recommend that you log into the database to get the top 20 using LIKE, so that Javascript does not crash and your application performs better. You can take advantage of that Filter field.

  • Can Carlos put the code you have? HTML and/or Javascript?

  • 1

    I think he meant that every time you scroll down it generates +20 records until it’s over (type max(or limit) and offset).

  • @Carlospereira you use Asp.net?

  • That’s right @Fsi, could be so too not to consume too much the application.

  • @Marconi, I’m using Java

  • @Carlospereira I put the Java tag on your question, you better identify which eah the language you use.

Show 2 more comments

2 answers

1

What is the need for a list of 5,000 options ?!

There’s no way to divide the weight of this load ?

JSON is usually quick and easy to handle, so the best alternative is to really split this view.

1


You can try something like this

$('#selectID').bind('scroll', function(){
    if($(this).scrollTop() + $(this).innerHeight()>=$(this)[0].scrollHeight){
        // sua chamada ajax. e dando sucesso, voce adiciona um ".html(data)" no ultimo item do seu select
        // ou utiliza o json aqui e faz a logica
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.