您好我正在尝试在Vaadin框架中编写网格过滤器。我的目标是用户有一个带下拉列表的组合框,可以选择他只想看3周,6周,9周前的条目。我写了它,但我有一个问题因为它不能作为默认过滤器。我的意思是,如果我打开一个页面,网格显示没有过滤器。我需要先点击按钮。是否可以默认过滤网格,仅显示3周的条目? 我该如何管理?
final ComboBox<Integer> timePeriodSelector = new ComboBox<>("Time Filter", Arrays.asList(3, 6, 9);
timePeriodSelector.setEmptySelectionAllowed(false);
timePeriodSelector.setTextInputAllowed(false);
timePeriodSelector.setValue(3);
timePeriodSelector.addValueChangeListener(this::onWeekChange);
...
private void onWeekChange(HasValue.ValueChangeEvent<Integer> event) {
switch (event.getValue()) {
case 3:
dateToCompare = LocalDate.now().minusDays(21);
break;
case 6:
dateToCompare = LocalDate.now().minusDays(42);
break;
case 9:
dateToCompare = LocalDate.now().minusDays(63);
break;
default:
dateToCompare = LocalDate.now().plusDays(21);
}
ListDataProvider<CcEvent> dataProvider = (ListDataProvider<CcEvent>) eventsOverview.getDataProvider();
dataProvider.setFilter(CcEvent::getReportingDate,
date -> compareDates(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), dateToCompare));
}
private Boolean compareDates(LocalDate dateFromTable, LocalDate dateFromFilter) {
return dateFromTable.isBefore(dateFromFilter);
}
答案 0 :(得分:0)
这段代码看起来不错,是网格过滤器的意图。
不过,您只需通过Function IncidentCancellAllActions()
Dim Rowcnt
Rowcnt = SwfWindow("VisionCommandClient").SwfObject("VisionCC_Incident_ActionsTab_SWO").WpfWindow("VisionCC_Incident_ActionsTab_WpfWin").WpfTable("VisionCC_Incident_ActionsTab_WpfTable").RowCount
If Rowcnt > 0 Then
SwfWindow("VisionCommandClient").SwfObject("VisionCC_Incident_ActionsTab_SWO").WpfWindow("VisionCC_Incident_ActionsTab_WpfWin").WpfTable("VisionCC_Incident_ActionsTab_WpfTable").ActivateCell
SendFromKeyboard("1-SHFT-F10")
wait 5
'SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").Select "Cancel All"
msgbox SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").ShowContextMenu
SwfWindow("VisionCommandClient").WpfWindow("VisionCC_ResourceStatusList_WpfWin_2").WpfMenu("VisionCC_Action_WPM").Select "Cancel All"
wait 2
Else
Exit Function
End If
End Function
电话切换setValue
来电。
在设置值之前设置侦听器可确保触发addValueChangeListener
!