[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-ui
Subject:    Re: XUL Tree Sorting -- RDF Appcore going away
From:       Robert John Churchill <rjc () netscape ! com>
Date:       1999-08-30 11:07:49
[Download RAW message or body]


Scott Putterman wrote:

> Robert,
>
> A couple of questions about this service.
>
> The first is that, I want to set a sort on a column before there is any content
> in it.  The reason is that I want it to sort the first time it gets loaded rather
> than have it get loaded and then sort.  When I do this, Sort returns an error
> code which becomes an exception in js.  This isn't a big deal because I can catch
> the exception and nothing bad happens, and when content appears, it is sorted.
> But, I'm wondering if this scenario is really a failure.

The sorting code currently considers it a failure as it needs a "context" of
information to know whether a sort is already active, what to sort, and how to sort
it.  That's not a big deal, so if its a problem for anyone, the sorting code could
just silently "fail" if it doesn't have enough info to figure out what/how to sort.

Take a look at  mozilla/xpfe/components/directory/directory.xul  and notice how the
"sortActive" and "sortDirection" attributes have default values assigned on the
appropriate <treecol> and  <treecell> tags.  That should do what you want, i.e.
impose an initial sort.  If not, let me know.  :^)


> The second is that I want to be able to sort menu items.  It looks like the code
> for sorting looks to see if it is a tree.  Can this be extended to menus and
> other widgets in general. For instance, I can imagine wanting the same thing for
> a combo box.

Currently, the sorting code is closely tied to trees for various reasons, including:

o  only trees use <treecol> tags, which indicate what (which RDF resource) to sort
on, as well as acting as a placeholder for the "sortActive" and "sortDirection"
attributes
o  trees have the magical <treechildren> tag under which child nodes are grouped,
unlike other objects like <menus>, etc.

If David is willing to add in equivalent new tags for other widgets, it might not be
too hard to get sorting working for generated content from XUL templates.  Otherwise,
its going to be tricky to sort anything other than trees.  I'll talk with David about
it... it seems like we need to replace the rather tree-specific <treecol> tag with a
more universal tag that can apply to more/any widget(s).

That said,a near-term cheat:   if you are building up something like a combo box with
STATIC items that come from your RDF datasource (such as context menu commands, for
example), the order the RDF datasource puts them into the enumerator is the order
that they should appear in the content. [Obviously this breaks down under aggregation
and other situations... so keep that in mind.]

Robert


["rjc.vcf" (text/x-vcard)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic