views:

766

answers:

7

I am working with an ASP.NET MVC application.

There is a requirement that a user be able to select an item from a ListBox that could contain over 30,000 entries.

Is there a dynamic way to populate the contents of this ListBox using an Ajax call - that would perform well?

Would I be better off just populating the ListBox control on the server and then having the user wait while the page renders with the 30,000 entries?

Would performance be better if I adopted some sort of jQuery solution?

Any suggestions on how to most efficiently deal with this scenario (without having the client change the requirement :-))?

+8  A: 

This sounds like a bad idea - 30,000 entries? How would you feel if you had to select from a list this size?

It is better to use autocomplete for this type of use case.

Vinay Sajip
+1 autocomplete/suggest the best route
redsquare
plug: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ is what I use for a large business system to autocomplete copious amounts of entries.
Kezzer
+1 for not using a listbox for 30K entries..
BigBlondeViking
With autocomplete I would still have to send all 30k+ entries down to the client initially?? I am guessing that would still cause a noticeable delay.
jsteele
You don't send all 30k entries at once. You start sending when the user has started typing (therefore you can query the result with the input string and probobly narrow it down alot). Good luck!
Mickel
no, autocomplete sends the input text to the server, the server will run a query against your data and return the matching results only, maybe limited to 10.
Phill Duffy
If it's a ListBox (as opposed to a ComboBox) you need to initially populate it with at least some of the entries.
Vinay Sajip
+2  A: 

The only answer to this question is: don't. Have you ever tried selecting something from a ListBox with 30,000 items? Has the client ever done this?

Update: I think the most efficient solution is to email a link to this page to your client, to give him a sense of the universal horror this question has evoked.

MusiGenesis
LOL! Like I said. I agree with you all. Just wanted to make absolute sure I was not overlooking something.
jsteele
A: 

If you load everything up front, the performance is only going to be as slow as it takes to download the markup and render it initially.

If you load everything through AJAX calls (jQuery or otherwise), it's going to have to make the request, download the results, parse the results, and render them to the page...which is even slower (especially for something that size).

I would ask why the ListBox needs so many entries. No user is going to be able to effectively use that control. Maybe cut down the size of the list and implement paging to make things a little more usable?

Justin Niessner
+1  A: 

Sounds like a complete madness.

How would a user feel if he had to scroll through 30000 entries? Also, for users with not perfect eyes and somewhat undeveloped motor skills to precisely manipulate a mouse the experience will be pain.

Don't do it. Use other approaches:

  • Paging of content, optionally with checkboxes to select items
  • Sorting of content according to various criteria
  • Categorize options for a user to first choose the right category and then select from a short list of options
  • If the precise selection is not important, try using Ajax technique to show a list with suggestions to choose from
  • Add a filter field for the user to define the pattern and let the rest just drop away

Another idea for your is to use an enhanced list supporting multiple columns and icons. Look at the Windows Explorer. It's much easier to select from a few columns with big icons than from a long list of minuscule text strings.

One more drawback of your approach: Having that many records at once in a select list will also expand the page size up to many megabytes. If you have the view state enabled, it will be quite slow and resource consuming.

Developer Art
I agree with all the comments above. We are converting an existing application which DOES have a ListBox with 30k+ items. The client is wanting to keep that behavior despite our suggestions to the contrary. I wanted to make sure I was not overlooking something.
jsteele
+3  A: 
voyager
A: 

30,000 items isn't actually that much from a performance perspective. Give it a try, in testing I have been able to put up to 100,000 items.

From a users perspective though, I'd say 1,000 items at the absolute maximum is probably the limit from a usability perspective. I usually stop at 100 items. I'd suggest adding a textbox right above your listbox. Allow the user to search for terms. You can use jquery to populate the box, or use an update panel. If you limit the results to 100 items this will be really fast.

Bob
A: 

Just use some good old fashioned validation; no need for a crazy listbox with every known option in the universe.