当前位置: 动力学知识库 > 问答 > 编程问答 >

java - How to open pickList of ComboboxItem/SelectItem manually/programatically using SmartGWT?

问题描述:

I'm using SmartGWT 2.5 with Java & Mozilla FF 3.6.x.

I want to open pickList of ComboboxItem or SelectItem manually that means programatically. Is it possible? It's ok if I need to use JavaScript to achieve this. Any hint or solution is appreciated.

Thanks in advance.

网友答案:

I finally got the answer. Posting it here might be useful to others. I've used

comboxItem.showPicker();

to achieve manual opening of picklist of ComboboxItem.

网友答案:

In SmartGWT 2.4 (I didn't check newer versions), the showPicker() method of SelectItem does only show an empty div, not the pick list of the select item. (It does work for the ComboBoxItem, as mentioned by RAS' answer).

Some digging into the underlying SmartClient code showed that on the JavaScript side, there is a showPickList() method which is called when the icon is clicked (or on some other events), but this is not exposed by the Java class.

So I used a piece of JSNI (modified from the source code of SelectItem.showPicker) to call this method:

public static native void showPickList(SelectItem item) /*-{
   var jsItem = [email protected]::getJsObj()();
   if(jsItem.showPickList) {
      jsItem.showPickList();
   }
}-*/

Calling showPickList(item) for any such pick list now opens the picker.

分享给朋友:
您可能感兴趣的文章:
随机阅读: