logo

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.

image

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.

Comments

  1. 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.

    • avatar
    • Jake Howlett
    • Mon 5 Oct 2009 05:20 AM

    I wasn't going to dwell on that Dragon, but now you mention it... ;o)

  2. 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

    • avatar
    • Erik Brooks
    • Mon 5 Oct 2009 07:08 AM

    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?

    • avatar
    • Jake Howlett
    • Mon 5 Oct 2009 07:14 AM

    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.

  3. @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....

  4. I also posted a slightly more indepth how to on the XPages Blog ...

    • avatar
    • Erik Brooks
    • Mon 5 Oct 2009 02:08 PM

    @Jeremy - Ah, got-it. Lazy-index FT search. Unfortunately not very scalable for large datasets that require up-to-the-second searches.

  5. 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.

    • avatar
    • Jake Howlett
    • Fri 9 Oct 2009 05:10 AM

    I like the sound of that Jerry. You setting yourself a challenge or was it meant for me?

    • avatar
    • Bruno Zottelo
    • Thu 5 Nov 2009 04:23 PM

    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

      • avatar
      • Jake Howlett
      • Fri 6 Nov 2009 02:39 AM

      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?

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Mon 5 Oct 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content