Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Displaying all unique values of descendent attribu (Read 3205 times)
Rob Forsyth
Full Member
*
Offline



Posts: 63

Displaying all unique values of descendent attribu
Mar 08th, 2013, 11:52am
 
I am looking for help with a $DisplayExpression. I hope an example will make this clear.

- Parent with $UserAttribute "A"
  • - child note with $UserAttribute "B"
    - child note with $UserAttribute "B, C, D"
    ---grandchild note with $UserAttribute "P, Q"
    - child note with $UserAttribute "C, D, E"
    - child note with $UserAttribute "E, F"


I want a $DisplayExpression for the parent note that equates to "A, B, C, D, E, P, Q" i.e. one occurrence only of each of the values represented in the $UserAttributes for it and all its descendents. Ideally this would be recursive so any note displays the list of unique $UserAttribute's of it plus all its descendents.

Is this feasible?

Thanks

Rob
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Displaying all unique values of descendent attribu
Reply #1 - Mar 8th, 2013, 11:59am
 
Let's do this step by step.

You want a note to display something like this:

    Roosevelt: A;C;Q

to show that the values of descendants of Roosevelt have one or more A's, C's, and Q's.  So the DisplayExpression will be something like

    $Name+": "+$SomeAttribute

What kind of attribute should it be?  A set attribute,clearly.

    $Name+": "+$MySet

Now, how do we compute MySet?  We might add a rule:

    $MySet= ...collect all the value of $MyAttribute used by my descendants

To do this, we'll probably use collect:

   $MySet=collect(descendants,$MyAttribute)

That's where I'd start, anyway.
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Displaying all unique values of descendent attribu
Reply #2 - Mar 8th, 2013, 12:12pm
 
To get from "Roosevelt: A;C;Q" to "Roosevelt: A, C, Q" requires a light touch of the format brush to the $DisplayExpression suggested above:

$Name+": "+$MySet.format(", ")

More on .format() for set and lists.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rob Forsyth
Full Member
*
Offline



Posts: 63

Re: Displaying all unique values of descendent attribu
Reply #3 - Mar 8th, 2013, 5:14pm
 
Thank you once again - perfect! (In fact semicolons just fine but thank you Mark A for extra finesse!)
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print