Restricting View To Multiple Categories With Flex
Before I showed you Flex's take on categorised views last week I was hoping to have added one extra feature to it - the ability to select more than one category to display at a time.
At first I thought it might be pushing the limits of E4X's XML-filtering, but then I asked the Stackoverflow.com crew whether you can filter XML with multiple nodes values against an array of multiple values to match. As expected, it can't be done natively with E4X. But you can easily extend it to do so. See the link above if you want to know how.
Notice in the screenshot below that I've selected more than one category from the "list". Click the image to see the updated demo. Once there hold down Ctrl while selected skills to do the same.
Notice also that the example above says it is showing 741 of the 2500 documents loaded, but this isn't the sum of the totals for each of the three categories chosen (409+397+3=809). That's because there are documents which exist in one or more of the three categories. Seems obvious, but thought I'd mention it.
Chalk up one more thing that Flex can do easily, that Domino has issues with.
Liking this Flex business more and more. Keep up the good work.
I wasn't going to dwell on that Dragon, but now you mention it... ;o)
Domino and XPages does do this, and doesn't have an "issue" with it ...
Sample:
http://beta219er.yellowbubble.org/YellowBubble/yb2.nsf/Providers-TagList.xsp
Way cool, Jake.
And you can still "group by" and resort as usual. That's a kick-ass grid.
Out of curiousity, when 8.5.1 is released (which I think is Tuesday) are you looking to upgrade to it any time soon? I'd be curious to see how this performs with a large data set (say, 30x what you've got here). 8.5.1's new on-the-fly GZIP compression should keep the XML down as it streams across the wire.
@Jeremy - Care to share how? I'll assume that isn't using the "categoryFilter" argument (the classic Domino dev "Restrict To Category" argument), since that can't take a Vector object. Or am I wrong?
Erik, I'd not really thought about it but I'll try and get Prominic to upgrade me as soon as they can to 8.5.1, so we can see what effect GZip has on it.
@Erik -
Sure - You are correct, I don't use categoryFilter property. I use the search property, and build a query based on the category field...
In the YellowBubble example, I store the selected tags in the viewScope, by binding the ListBox with the selections to the variable named 'selectedTag' in viewScope. Then the listbox's onchange event is set to do a partial refresh on the appropriate region. Then in the search parameter for the data (Dommino View defined at the XPage level [outside the area of the partial refresh]), I use the following code as a computed value to filter the view:
try {
return "FIELD ProductKeywords CONTAINS " + viewScope.selectedTag.join(' OR ');
} catch (e) {
return "FIELD ProductKeywords CONTAINS " + viewScope.selectedTag
}
The try { } catch { } basically just tries to execute the code in the try block first, and if there is an error (for example there is only 1 value in viewScope.selectedTag so its not an array) then it executes the code in the catch block....
The result is selected multiple categories....
I also posted a slightly more indepth how to on the XPages Blog ...
@Jeremy - Ah, got-it. Lazy-index FT search. Unfortunately not very scalable for large datasets that require up-to-the-second searches.
Looking at your screen grab, it occurs to me that flex would be easy enough to make a OS X "Finder" style tree lookup where the next level is appended as a new column. Though that probably breaks the way the data grid likes to use xml... visually though, it doesn't have far to go and I really like the finder columnar tree model.
I like the sound of that Jerry. You setting yourself a challenge or was it meant for me?
Sorry Jake, I'm using only Flex SDK (3.4) and couldn't compile the flex code stored in NSF...
I need Flex Build ?
Thanks
Hi Bruno,
I've never used the SDK alone so I don't know what the problem might be, but yes, I suspect you need Flex Builder. The demo uses the AdvancedDataGrid, which I don't *think* is in the SDK?