To keep things simple, I’m using a PieChart to filter the results in a table. I’m doing it differently than Cuba expects. I use SliceClickListeners instead of OnSlicePullOut and OnSlicePullIn to adjust the query in the CollectionDatasource. A problem occurs when I have already adjusted the dataSource with the pie chart, then try to use the Custom Query I have created. What can I add to the custom query to fix this?
xml
<collectionDatasource id="itemsDs"
class="company.entity.item.Item"
view="item-view">
<query>
<![CDATA[select e from edge$Item e]]>
<filter>
<and>
<c>
<![CDATA[e.createTs >= :custom$startDate]]>
</c>
<c>
<![CDATA[e.createTs <= :custom$endDate]]>
</c>
</and>
</filter>
</query>
</collectionDatasource>
...
<groupBox id="selectBetweenFilter"
collapsable="true"
collapsed="true"
caption="Select within range"
orientation="horizontal"
spacing="true">
<hbox spacing="true">
<label align="MIDDLE_LEFT"
value="Start date"/>
<dateField id="filterStartDate"
dateFormat="MM/dd/yyyy"
resolution="DAY"/>
<label align="MIDDLE_LEFT"
value="End date"/>
<dateField id="filterEndDate"
dateFormat="MM/dd/yyyy"
resolution="DAY"/>
<button id="applyFilterBtn"
caption="Apply"
invoke="applySelectBetweenFilter"/>
</hbox>
</groupBox>
And in ItemBrowse.java
public void applySelectBetweenFilter() {
Map<String, Object> params = new HashMap<>();
Date startDate = filterStartDate.getValue();
Date endDate = filterEndDate.getValue();
if (startDate != null) {
params.put("startDate", startDate);
}
if (endDate != null) {
params.put("endDate", DateUtils.addDays(endDate, 1));
}
itemsDs.refresh(params);
}