Filter Data in a Range"

From Documentation
m
Line 9: Line 9:
 
===Purpose===
 
===Purpose===
 
Filtered data display rows that meet provided criteria, and hide those trivial ones.
 
Filtered data display rows that meet provided criteria, and hide those trivial ones.
 +
 +
[[File:ZKSsEss_Spreadsheet_FilterData_Hide222.png]]<br/>
  
 
===AutoFilter===
 
===AutoFilter===
Line 15: Line 17:
 
===Reapply filter===
 
===Reapply filter===
 
If contents within AutoFilter range has been added, modified or deleted, reapply the current filter can force the sheet to update the result per the current filter criteria. Use <javadoc directory="zss" method="applyFilter()">org.zkoss.zss.model.Range</javadoc> to reapply current filter.
 
If contents within AutoFilter range has been added, modified or deleted, reapply the current filter can force the sheet to update the result per the current filter criteria. Use <javadoc directory="zss" method="applyFilter()">org.zkoss.zss.model.Range</javadoc> to reapply current filter.
 +
 +
[[File:ZKSsEss_Spreadsheet_FilterData_Hide222_Reapply.png]]<br/>
  
 
===Clear filter===
 
===Clear filter===
 
Use <javadoc directory="zss" method="showAllData()">org.zkoss.zss.model.Range</javadoc> to clear current filter.
 
Use <javadoc directory="zss" method="showAllData()">org.zkoss.zss.model.Range</javadoc> to clear current filter.
 +
 +
[[File:ZKSsEss_Spreadsheet_FilterData_ClearFilter.png]]<br/>
  
 
===ZUML===
 
===ZUML===

Revision as of 06:23, 24 May 2011


Available in ZK Spreadsheet EE only

ZK Spreadsheet can filter data to find a subset of data in a range.

Purpose

Filtered data display rows that meet provided criteria, and hide those trivial ones.

File:ZKSsEss Spreadsheet FilterData Hide222.png

AutoFilter

Use Range.autoFilter() to toggle AutoFilter for sheet in a range. After applied AutoFilter, user can specify criteria by calling Range.autoFilter(integer, object, integer, object, boolean) to filter data in a range.

Reapply filter

If contents within AutoFilter range has been added, modified or deleted, reapply the current filter can force the sheet to update the result per the current filter criteria. Use Range.applyFilter() to reapply current filter.

File:ZKSsEss Spreadsheet FilterData Hide222 Reapply.png

Clear filter

Use Range.showAllData() to clear current filter.

ZKSsEss Spreadsheet FilterData ClearFilter.png

ZUML

<zk>
<div height="100%" width="100%" apply="org.zkoss.zssessentials.config.AutoFilterComposer">
	Criteria: hide "222"
	<div>
		<button id="autoFilter" label="Toggle AutoFilter" mold="trendy"></button>
		<button id="reapplyAutoFilter" label="Reapply AutoFilter" mold="trendy"></button>
		<button id="clearAutoFilter" label="Clear AutoFilter" mold="trendy"></button>
	</div>
	<spreadsheet id="spreadsheet" src="/WEB-INF/excel/config/autoFilter.xlsx"	
				maxrows="200" 
				maxcolumns="40"
				width="100%"
				height="450px"></spreadsheet>
</div>
</zk>

Composer

Toggle AutoFilter

Spreadsheet spreadsheet;
int rowIndex;
int columnIndex;
public void onClick$autoFilter() {
	AutoFilter autoFilter = Ranges.range(spreadsheet.getSelectedSheet(), rowIndex, columnIndex).autoFilter();
	alert(autoFilter == null ? "Clear AutoFilter" : "Applied AutoFilter");
}

Reapply AutoFilter

public void onClick$reapplyAutoFilter() {
	Ranges.range(spreadsheet.getSelectedSheet()).applyFilter();
}

Clear AutoFilter

public void onClick$clearAutoFilter() {
	Ranges.range(spreadsheet.getSelectedSheet()).showAllData();
}

View complete source of ZUML autoFill.zul

View complete source of composer AutoFilterComposer.java

Version History

Last Update : 2011/05/24


Version Date Content
2.1.0 May, 2011 AutoFilter
     


All source code listed in this book is at Github.


Last Update : 2011/05/24

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.