Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi.
Can anyone share example of TableViewDescriptor usage to filter list of persistables?
I need java code.
Thanks.
ps:
for example i have:
TableViewDescriptor myCustomTVD = ...;
List<Persistable> persistableList = ...;
and nothing more.
What sequence of methods should i use to get filtered list of persistables according to filter in TableViewDescriptor?
Hi,
try with this code:
Vector criterionVector = new Vector(); TableViewCriterion localTableViewCriterion = TableViewCriterion.newTableViewCriterion("objType", "EQUALTO", "WCTYPE|wt.projmgmt.admin.Project2|com.acme.MyProject", null); criterionVector.add(localTableViewCriterion); tableViews.add(tableviewdescriptor);
Yo can create filters in a custom view and export it to see the attributes to use.
Regards
Iker Mendiola - Prambanan IT Services |
I find some related sample code as below:
private TableViewDescriptor getActiveProjectView(String tableId) throws WTException, WTPropertyVetoException {
TableViewCriterion STATE_DEFINED = TableViewCriterion.newTableViewCriterion(ProjMgmtConstants.STATE_KEY,
OperatorConstants.EQUALTO, ContainerTeamManagedState.DEFINED.getStringValue(), null);
TableViewCriterion STATE_RUNNING = TableViewCriterion.newTableViewCriterion(ProjMgmtConstants.STATE_KEY,
OperatorConstants.EQUALTO, ContainerTeamManagedState.RUNNING.getStringValue(), null);
String name = getViewResourceEntryKey(ORG_RESOURCE, "VIEW_ACTIVE_PROJECTS");
String description = getViewResourceEntryKey(ORG_RESOURCE, "VIEW_ACTIVE_PROJECTS");
Vector criteria = new Vector(1);
criteria.add(STATE_DEFINED);
criteria.add(STATE_RUNNING);
TableViewDescriptor tv = newTableViewDescriptor(name, tableId, true, true, getColumnsToDisplay(), criteria, false, description);
List<SortColumnDescriptor> sort = new ArrayList<SortColumnDescriptor>();
SortColumnDescriptor lastModified = new SortColumnDescriptor(ColumnIdentifiers.LAST_MODIFIED, SortColumnDescriptor.ASCENDING);
sort.add(lastModified);
tv.setColumnSortOrder(sort);
return tv;
}