Excellent post by Nick http://adfcodebits.blogspot.com/2010/11/bit-25-hiding-view-criteria-item-based.html
just reposting some of the code
/**
* Hides a view criterion.
* Example: The following will hide the SourcePolicyNbr criterio if the condition
* is true. If the condition is false, it will show the criterio in BOTH basic and
* advanced.
*
* hideCriteriaItem("SomeCriteria", "SomeCriteriaItem",
* someCondition==true, ViewCriteriaItemHints.CRITERIA_RENDERED_MODE_BOTH);
*
*
* @param viewCriteriaName the view criteria name
* @param criteriaItemName the criterio name
* @param condition the HIDE condition
* @param showHint the SHOW hint
*/
protected void hideCriteriaItem(String viewCriteriaName,
String criteriaItemName, boolean condition,
String showHint) {
if (viewCriteriaName != null) {
ViewCriteria v = this.getViewCriteria(viewCriteriaName);
if (v != null) {
boolean found = false;
while (v.hasNext() && !found) {
ViewCriteriaRow vcr = (ViewCriteriaRow)v.next();
if (vcr != null) {
ViewCriteriaItem[] vcis = vcr.getCriteriaItemArray();
if (vcis != null && vcis.length > 0) {
for (int j = 0; j < vcis.length && !found; j++) {
ViewCriteriaItem vci = vcis[j];
if (vci != null && criteriaItemName != null &&
criteriaItemName.equals(vci.getName())) {
found = true;
vci.setProperty(ViewCriteriaItemHints.CRITERIA_RENDERED_MODE,
condition ?
ViewCriteriaItemHints.CRITERIA_RENDERED_MODE_NEVER :
showHint);
v.saveState();
}
}
}
}
}
}
}
}
No comments:
Post a Comment