我有以下要求。
有一个select项目有一个pickList,它是一个ListGrid,带有用于多选的复选框。 一旦用户选择了记录,用户就必须手动点击picklisticon(选择项旁边(右侧)的向下箭头),或者他可以点击选择项旁边的任何地方以关闭pickList。 现在我想在用户选择他想要的记录后,当鼠标移出listGrid(pickList)时关闭此pickList。 这是因为,在选择记录后,有一个用户单击以保存表单的按钮。只有在手动点击向下箭头或选择项目之外的任何位置时,才会关闭选项列表,然后单击“应用”按钮。
有什么办法可以实现这个功能吗?
以下是代码
VLayout layout = new VLayout();
final ButtonItem button = new ButtonItem("button","Apply");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
SC.say("You clicked me");
}
});
final ListGrid pickListProperties = new ListGrid();
pickListProperties.setShowHeader(true);
pickListProperties.setCanGroupBy(false);
pickListProperties.setAutoFetchData(true);
pickListProperties.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
GWT.log("Closing the pick list of the select item");
pickListProperties.hide(); // Not sure how to get the arrow down item and fire the click event on this so that pickList is closed.
button.focusInItem();
}
});
ListGridField descrField = new ListGridField("description","Names");
DataSourceTextField dsField = new DataSourceTextField("description","Names");
dsField.setMultiple(true);
DataSource optionalDS = new DataSource();
optionalDS.setDataURL(GWT.getModuleBaseForStaticFiles()+"optional.xml");
optionalDS.setFields(dsField);
final SelectItem selectItem = new SelectItem("Name","Select");
selectItem.setPickListHeight(100);
selectItem.setSelectOnFocus(true);
selectItem.setPickListFields(descrField);
selectItem.setPickListProperties(pickListProperties);
selectItem.setPickListWidth(350);
selectItem.setOptionDataSource(optionalDS);
selectItem.setMultiple(true);
selectItem.setAllowEmptyValue(false);
selectItem.setMultipleAppearance(MultipleAppearance.PICKLIST);
// selectItem.sett trigger
DynamicForm hdf = new DynamicForm();
hdf.setFields(selectItem,button);
layout.addMember(hdf);