简体   繁体   English

在gwt Suggest Box中添加更多按钮

[英]Add a more button to gwt Suggest Box

I have a gwt suggest box that does an RPC call to get some data from the server and display it. 我有一个gwt建议框,它执行RPC调用以从服务器获取一些数据并显示它。 In some cases there are up to 2000 results. 在某些情况下,最多有2000个结果。 Whilst this works fine in chrome when the javascript runs in firefox it freezes the window for 5 seconds and sometime brings up script not responding warnings. 虽然在Firefox中运行javascript时这在chrome中工作正常,但它会冻结窗口5秒钟,有时会导致脚本没有响应警告。

What I wanted to do was something like show 20 results and have a more button that can just append the next 20 without having to call back to the server every time it is clicked. 我想要做的就是显示20个结果,并且有一个更多按钮,只需追加下一个20,而不必在每次点击时回叫服务器。 I am fairly new to this, I have tried extending suggestBox and overriding showSuggestions() but it is protected so I can't. 我是相当新的,我已经尝试扩展suggestBox和重写showSuggestions()但它受到保护所以我不能。

Any suggestions/ ideas would be great. 任何建议/想法都会很棒。

Cheers, Rob 干杯,罗布

See this question for pointers on how to extend the GWT's SuggestBox - basically, you want to provide your own SuggestOracle (it's used for fetching the suggestions), maybe your textbox (see the links in the question I mentioned earlier) and most likely a custom SuggestBox.SuggestionDisplay . 请参阅此问题以获取有关如何扩展GWT的SuggestBoxSuggestBox - 基本上,您希望提供自己的SuggestOracle (它用于获取建议),也许是您的文本框(请参阅我之前提到的问题中的链接),并且很可能是自定义SuggestBox.SuggestionDisplay Those three are passed via the constructor to SuggestBox . 这三个通过构造函数传递给SuggestBox See the existing default implementations ( MultiWordSuggestOracle , SuggestBox.DefaultSuggestionDisplay ) for some ideas :) 一些想法,请参阅现有的默认实现( MultiWordSuggestOracleSuggestBox.DefaultSuggestionDisplay ):)

If you want to change source code of SuggestBox see this you should create com.google.gwt.user.client.ui packeges in your src root and copy there SuggestBox.java. 如果你想改变SuggestBox的源代码,看到 ,你应该在你的src根目录中创建com.google.gwt.user.client.ui packeges和复制有SuggestBox.java。 When you use SuggestBox it calls your SuggestBox which is in your src. 当你使用SuggestBox时,它会调用你的src中的SuggestBox。
Check this also it can be useful too 检查一下也很有用

First solution come to mind is that write your own widget which extends from SuggestBox and the second solution maybe change the default css parameters of suggestbox 首先想到的解决方案就是编写自己的小部件,从SuggestBox扩展而第二个解决方案可能会改变suggestbox的默认css参数

.gwt-SuggestBox {
}
.gwt-SuggestBoxPopup {
}
.gwt-SuggestBoxPopup .item {
}
.gwt-SuggestBoxPopup .item-selected {
}
.gwt-SuggestBoxPopup .suggestPopupContent {
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM