Submitted by eu on 2018/05/31 11:30
I would like to make this filter: Only show subitem if the item is the main parent of that given subitem.
 
First usage scenario: I have a first grid (Books) in which the itens are books and the subitems are notes about those books; and a second grid (Thesis) in which the items are chapters of my thesis, and subitems are my paragraphs. Then I make some of the subitems from Books grid children of some of the items of the Thesis grid, as second parents. That's the structure, but, sometimes, I want to look at the Thesis grid and view only the chapters and paragraphs, without the book notes.
A possible workaround would be to autoassign a field to every item of Books grid and then filter by this field(EDIT: the best way to deal with this scenario is filtering by Item Home). But that wouldn't work in the second usage scenario...
 
Second usage scenario: (given the structure described above) In Books grid, I make a subitem of book 1 to be also a child of book 2. But, sometimes, I want to see book 2 only with it's original notes (the ones to which it is the main parent).
 
The filter I described would deal with both the cases.
 
I think those operations will be easier when IQ have more kinds of relantionship, as it's being discussed here: http://www.sqlnotes.net/drupal5/index.php?q=node/4209
 
Thanks!

Comments

 PS: It would also be nice to use this criteria (Only show subitem if the item is the main parent of that given subitem) for conditional formatting. So, for example, in my Thesis grid, the book notes would be marked with a different color.

I don't think you need to filter by main parent (I don't think it's possible at the moment -- but it could). Although it would be nice to be able to that, eventually.
 
What can be used is context parents, as context parents use the main parent for contextualisation. Did you try that?
 
I had a similar setup as yours, and what I did is identify all those book notes with a special field (or tag -- whatever you prefer).
It could be a "bookNote" or a "bookComment" or a "quotation" field. Every time to take a note, just assign that field. It's quite quick. I use an automated process to assign other values with popups, autoassigns, etc., but I don't have the time to go into that now.
The more you precise items with different fields, the more precise your filtering can be. There's a balance to be found between that sophistication and convenience, obviously.
 
As for conditional formatting, it's then easy to use whatever field specification to format items as you wish.

Thanks! What I did to deal with both scenarios: assign every subitem of Books grid to the Books Source + Tree View + Context Parents; and, in the Thesis grid, filter out by the Book Source.
 
But, there's still one unsolved situation: take the second scenario above; what if I want a conditional formatting so the subitem that have book 1 as it's main parent only gets background color if it's appearing as the child of other parents. It would be like this:
 
  • Book 1
    • note 1.1
  • Book 2
    • note 2.1
    • note 1.1
In that case, the only variable that differentiate the note 1.1 clone is appearing as the child of a "not main parent" parent. 
 

Armando

2018/05/31 16:14

In reply to by eu

That's a pretty old post! Almost 10 years!  :)  No... the automated process I was talking about is different, and not necessarily appropriate in your case.
 
 
One solution, of the top of my head : you could probably try some condition based on the value of "itemparent" and some field containing the title of the book.
That would imply that -- maybe -- checking the y/N field of a note, would insert the books title taken from the itemParent's value.
 
So in some Boolean field called IsaNote, you would have that auto-assign
A:BookTitle=[itemParent]
E:BookTitle=
 
Where BookTitle is a String field used to store the itemParent's value, for eachitem, and isAnote a field that defines a note. Obviously, the itemparent must have the book title as its item value
 
So for any note, you check "isANote", which assigns a value (the itemparent's value) to its "BookTitle" field.
 
Then, in the item field properties, for the conditional formatting, you can try Something like 
 
Criteria
[item]=[booktitle]  
Formats
backcolor=&h97E4F0
 
You get the idea? Seems like this should work... Have to go now...

eu

2018/05/31 17:36

In reply to by Armando

 But this criteria would only be met if the subitem had the same name as the parent. So, in the example above, for the subitem "note 2.2" under Book 2, it would result:
 
 
       note 1.1 = Book 1 (criteria not met)
 
 
Am I missing something?

Armando

2018/06/01 11:02

In reply to by eu

As I was writing quickly I just reversed the logic. Just replace
[item] =
by
[itemparent] <>
Disclaimer : it should work, but I haven't tried it.

Armando

2018/06/01 15:53

In reply to by eu

[quote=eu]
 
Maybe you are forgetting the fact that the Itemparent field always shows the main parent (as pointed here http://www.sqlnotes.net/drupal5/index.php?q=node/4190)?
[/quote]
 
You're right, I momentarily forgot that. The value always shows the main parent, so it can't work. Sorry.
 
It would probably need to be done at the "grid level", since I think only the grid registers what hierarchy is currently displayed. It should be possible since the status bar can show the currently displayed parent OR the main parent. Pierre will tell.
 
In the mean time, you could probably color the item based on the nbparents value. It's not perfect, but at least you'll know a note has several parents and so it could be that it's not under its main parent.
 

 I just noticed that the best way to deal with the first scenario alone is filtering by Item Home, instead of the workaround I proposed originally. I corrected that in the post.

Armando

2018/06/01 11:04

In reply to by eu

 itemHome will work fine as long as those items always have the same home grid.

eu

2018/06/01 13:33

In reply to by Armando

 Yes, it wouldn't work if I had also a News grid, and some items of it as children of the Thesis grid, but I wanted to see the Thesis grid with only the Books grid items hidden.

Armando

2018/06/01 21:19

In reply to by eu

Or maybe with a smart field, but I don't know how to get the current parent value (not the main parent).
 
We should be able to create a smart field showing the current parent and comparing that to the ItemParent Field for the conditional formatting.
 
In the options section of a new "CurrentParent" field, there would be something like
 
<Source>SELECT ¯Items.CurrentParentID AS CurrentParent, ¯Items.ID AS ItemID FROM ¯Items;</Source>
 
What I bolded is the mystery value. For the main parent, you'd just type ParentID.

EDIT:
I thought it could be done with column equations, but "obviously" it cannot.
 

Perhaps this will do what you want... In v109:
  • New: Grid: Hold Shift when expanding an item will only display main children. Hold Ctrl will show all children. Main children are sub-items for which the item is the main parent
HTH !
 
Pierre_Admin
IQ Designer