Reputation: 1288
I have extensive experience in windows forms but beginner in asp.net mvc. In my windows form applications it's common to include a textbox where user must enter a business partner (his id to be precise) for example. Often users don't know this ID so I provide autocomplete which works on his ID or his name. But, sometimes that is not enough either so the textbox is within an user control which has a search button which in turn opens a dialog form where user can search his dictionary by name, adress, phone number, etc... This scenario is very common in my applications.
So, how would I handle this scenario in asp.net mvc in a consistent manner? What are the best practices for handling lookups which are too big for simple dropdown/autocomplete textbox?
Thanks.
Upvotes: 2
Views: 979
Reputation: 1028
The strategy I think depends on the amount of data you're working with. First let's start with control itself, you can go with
Select2: here is the link
jQuery Chosen: here is the link
Or even a simple autocomplete: here is the link All these controls have built-in search, locally or remotely.
If you don't have a large amount of data you can load it all at once and search locally, or, you can search remotely.
If you look at select2 Loading Remote Data section it's show how you can get from your server. Let me know if you need more help with that.
Upvotes: 0
Reputation: 101614
Well, in JavaScript you can use a popup window or (for a more modern approach) use a jQuery-UI Dialog and display the form to the user (which could be a partial view or a rendered ChildAction
). One the user's done making a selection you can bind to the dialog closing and place the final result back in the original ID.
Upvotes: 1