views:

36

answers:

1

The basic problem: selecting a few items from a list of thousands.

The potential solution:

I have an autocomplete field that searches the db, and returns a name/id pair. This is working fine.

The next step is to preserve the selected IDs, and allow the user to remove some if needed. For this, I've been looking at using a select, and was hoping a UI something like that provided by this, but it doesn't work: it allows you to select items that already exist in the select, but doesn't work with a dynamically created select.

The final step is a traditional postback (using a submit button, this is in asp.net webforms) where I'll need to have access to the final list of IDs.

Are there other options for this?

+4  A: 

Based on your comments below, there are a lot of ways to skin this cat. The following approach is similar to the SelectList idea only it doesn't use a dropdown list. The nice thing about the Listbox versus the DropdownList is that the user will be able to view many items at once. Of course, the choice of using a Listbox or a DropdownList doesn't really matter as they both essentially provide the same functionality. The key about this answer is that values are stored on the client until you're ready to submit.

  1. Create an autocomplete textbox that dynamically fills a Listbox as you type.
  2. Clicking on a Listbox item results in two things happeing:
    1. The ID of the selected item is stored in a client-side array
    2. A list of items are rendered/re-rendered on the page exactly like the SelectList. Clicking the red 'X' will remove the ID from the array and re-render the list. You'll have to do a bit of jQuery coding on your side but it isn't much.
  3. The above steps are repeated until the user has selected all of their items.

Upon clicking "Save", only the selected items are submitted to the server for processsing.

Alison
The main problem is creating a UI for picking a few items out of a list of thousands, without doing a traditional postback each time. Performance is not a problem, so caching isn't really going to help anything at this point.
chris
Ah, I see. If db performance isn't a problem then autocomplete is a great way to go. Are you saying you want to have autocomplete dynamically populate a dropdown list? I'm still having trouble seeing your problem.
Alison
Autocomplete is good for picking a single item. I need to accumulate N items on the page before the final submit. How can I store the values in a structure on the page that I can use after the final submit? Note that in addition to adding to the selected list, users should be able to remove items that they have already selected. There doesn't seem to be a good UI for this scenario.
chris
Makes perfect sense. I've updated my answer to continue the discussion.
Alison
That's still a 2-step process, which won't really work for my user community.
chris
I'm a bit confused. I don't really see how this is a 2 step process. A user searches, finds the desired option, and selects that option. Do you mean the second step requires a user to go back and search the list additional times? According to your question, you seemed fine with the process but couldn't use SelectList because it didn't allow for dynamic options. My solution allows for dynamic options. Moreover, if the autocomplete suggestion is flexible enough, it can load enough options to allow a user to multi-select. Search, select, save. Seems like a reasonable option.
Alison