Data Validation"
From Documentation
m (Created page with "{{ZKSpreadsheetEssentialsPageHeader}} __TOC__ {{ZSS EE}} ===Purpose=== Data validation is invaluable when a workbook share with other users in a organization, to make sure the d...") |
m |
||
Line 77: | Line 77: | ||
| Since 2.2.0 | | Since 2.2.0 | ||
| January, 2012 | | January, 2012 | ||
− | | Support | + | | Support Data Validation |
|- | |- | ||
| | | |
Revision as of 00:43, 11 January 2012
Available in ZK Spreadsheet EE only
Purpose
Data validation is invaluable when a workbook share with other users in a organization, to make sure the data entered in the workbook to be accurate and consistent.
Data Validation
Validation message
Prompt
Error alert
Click cancel button will remove editing value
Click retry button allow user to continue editing cell value without empty editing value
Validation list
ZUML
<div apply="org.zkoss.zssessentials.config.ValidationComposer" width="100%" vflex="1">
<combobox id="deparmentCombobox">
</combobox>
<spreadsheet id="spreadsheet" src="/WEB-INF/excel/config/validation.xlsx"
maxrows="100" maxcolumns="20"
width="100%" vflex="1">
</spreadsheet>
</div>
Composer
private DataValidation getDataValidation() {
return sheet.getDataValidation(DATA_VALIDATION_ROW, DATA_VALIDATION_COL);
}
private void initCombobox() {
DataValidation dataValidation = getDataValidation();
DataValidationConstraint constraint = dataValidation.getValidationConstraint();
switch (constraint.getValidationType()) {
case ValidationType.LIST:
ListModelList model = new ListModelList(constraint.getExplicitListValues());
deparmentCombobox.setModel(model);
break;
}
//Add illegal item
((ListModelList) deparmentCombobox.getModel()).add("Illegal cell value");
}
public void onSelect$deparmentCombobox() {
String cellValue = deparmentCombobox.getSelectedItem().getLabel();
boolean validInput = spreadsheet.validate(sheet, DATA_VALIDATION_ROW, DATA_VALIDATION_COL, cellValue, null);
if (validInput) {
Ranges.range(sheet, DATA_VALIDATION_ROW, DATA_VALIDATION_COL).setEditText(cellValue);
}
}
Version History
Version | Date | Content |
---|---|---|
Since 2.2.0 | January, 2012 | Support Data Validation |
All source code listed in this book is at Github.