Subscribe via FeedPaul Hannan, Aug 19, 2010 1:19:49 PM
As requested and hot on the heels of yesterday's post on multi-level categoryFiltering enhancement, here is an example of how you can filter multiple sorted non-categorized columns with a vector. And here we're using the 'keys' property which allow you to filter a view of sorted non-categorized columns.
For this example you won't have to wait until 852 is out next Tuesday, this is something you can do right now. And again we're going to use the XPages Demo App from OpenNTF to show this in action.
So here's what we got.
Firstly we got three comboboxes and the selection of these will form our vector for which the view with the three corresponding columns will be filtered. Each value is bound to a scoped variable.
@Unique(@DbColumn(@DbName(),"xspFiltersView",1))}]]>
@Unique(@DbColumn(@DbName(),"xspFiltersView",2))}]]>
@Unique(@DbColumn(@DbName(),"xspFiltersView",3))}]]>
submit="true" refreshMode="complete" immediate="false"
save="true">
Then we use the scoped variables to calculate vector.
...
var vtr:java.util.Vector = new java.util.Vector();
var t1 = requestScope.val01;
var t2 = requestScope.val02;
var t3 = requestScope.val03;
@If(t1 !=null,vtr.addElement(t1),vtr.addElement(""));
@If(t2 !=null,vtr.addElement(t2),vtr.addElement(""));
@If(t3 !=null,vtr.addElement(t3),vtr.addElement(""));
return vtr}]]>
...
So let's have a look at this in action. We got our three comboboxes which we're using to form our vector.

Selecting a value from the first combobox and then hitting the Filter View button composed the vector to filter the view with the value from the first column and then null for the following two columns.

Selecting a value from the second combobox along with the first computes the vector with two values and null for the third column.

Filling out the vector with a third selection completes the filtering options.

Download sample here and blog post here.
Hope this helps.
p.
9 responses to XPages multi-column filtering using a vector of non-categorized columns
Dick Stagnone, September 16, 2010 12:22 PM
Thank you for following up and providing this post. I will review it and share it with my team.
Ravi, September 12, 2010 4:54 PM
Thanks for the nice article. I tried implementing this code. I downloaded the application from openntf and copied the code provided to an xpage. But when I try to open the xpage, I get an error "Item not found exception". I am using 8.5.2 Client and server. All the other examples work fine in the application. What could be the probable reason?
Fredrik Stöckel, August 22, 2010 6:43 PM
Paul Hannan, August 22, 2010 6:19 PM
@Fredrik - the Multiple Category filter enhancement request is already in there - PHAN86FKHY - I might just tag in the multiple 'keys' there too with the multiple categoryFilter request. They're more or less in the same boat.
Fredrik Stöckel, August 22, 2010 4:24 PM
+1 on the "multiple category" filter enhancement :)
Paul Hannan, August 20, 2010 5:44 PM
Hi Nathan,
Haven't tried it but I reckon it won't work. Right now it would fail - it won't find one match on the column and then continue down the column to get the next and so on. At best it would look for a match on the next column.
So it's an enhancement request. And this kinda falls into the multiple category filter (which I'd like to see ) enhancement request.
Can this be done in the eXtAPI and eXtLib? If you can do it that will save us a lot of trouble... ;-)
p.
Nathan T. Freeman, August 19, 2010 9:34 PM
Paul, if one element of the Vector is itself a Vector or an array, can I get multiple value matches for that column? So, say...
[AA, [LL,LM,NLM]]
Would that work?
If not, consider it an enhancement request. And one that I might even simply fulfill in the Extensibility Library. :-)
Paul Hannan, August 19, 2010 6:27 PM
Hi Sean,
Yes that will work in the sample above.
It'll also return if you just select something the 2nd and 3rd option and leaving the first null something will be filtered as long as something exists - but it may not return what you expect at first glance.
If you choose to filter the view by the 3rd option in the vector it will return the first find as it depends on the sorting of the preceding two columns. So a health warning I guess.
p.
Sean Cull, August 19, 2010 4:10 PM
Paul, am i correct in thinking the filters need to be used sequentially ?
Can you choose to use filters 1 and 3 only ?
tks, Sean