开发者

Grails Dynamic Search like google

开发者 https://www.devze.com 2023-02-10 14:22 出处:网络
I am building a Grails web application and am fairly new to grails. I am looking to do a search filter window/pane where as a employee st开发者_如何学编程arts to type a customers name/telephone number

I am building a Grails web application and am fairly new to grails. I am looking to do a search filter window/pane where as a employee st开发者_如何学编程arts to type a customers name/telephone number or account number in it filters the results in the window below. Kinda like google live search. Then the employee can choose the correct person from the box below.. I am trying to search MySQL data. I have looked at the Search and Filter Pane plugins and they say they are for search.. not that they dynamically display based on what is being typed in a box. I am supporting about 30 client computers but they run about 3000 to 5000 queries a day. Mostly look-ups by last name or phone.

What is the best way to implement this kind of auto complete with dynamic search results?


The GrailsUI plugin has autocomplete too. Unfortunately, that plugin isn't supported any more, but the autocomplete does work. And it's well documented. Probably best to go jquery, but you might give GrailsUI a look.


you need to stand up a server endpoint for search. You need to build or integrate an existing autocomplete widget on the client side. http://docs.jquery.com/UI/Autocomplete#options. Basically, you configure this widget to go to a URL after certain conditions are met (like user needs to enter 2 chars before a search happens)

The service endpoint can be really simple, but it needs to be fast, so you might want to consider using a second level cache if you are not already. Or you can start without the cache, and only use it if performance becomes an issue.

Since you identified search by name or phone number, you will of course need to use the jquery thing once for each, and you need a service method for each (or one service method that does both, passing in a param for byName or byPhone, but i would just do separate services).

Since you are searching on simple fields, I don't think you need to get the searchable plugin involved, but if you were searching thru fields with lots of text, you might want to use it.

0

精彩评论

暂无评论...
验证码 换一张
取 消