discovery icon indicating copy to clipboard operation
discovery copied to clipboard

Tree view doesn't work with properties containing object

Open obenjiro opened this issue 6 years ago • 2 comments

Data

[{ id: 1, a: { id: 3, val: 1 }}, { id: 2, b: [{ id: 4, val: 1 }]}]

View

{
    view: 'tree',
    children: 'a or b',
    item: [
    	'text:id', 'struct'
    ],
    expanded: 100
}

Actual Result 2019-02-21 12 54 36

Expected To see object with id 3 in tree

obenjiro avatar Feb 21 '19 09:02 obenjiro

Workaround that I have found. At least for now

{
    view: 'tree',
    data: '',
    children: '$r: (a or b) + []; $r.[size() > 1]',
    item: [
    	'text:id', 'struct'
    ],
    expanded: 100
}
2019-02-21 13 19 57

obenjiro avatar Feb 21 '19 10:02 obenjiro

One more workaround (a or b or []) + []

lahmatiy avatar May 27 '20 08:05 lahmatiy

A solution from 2024: a or b | is array ?:? [$] (or the full form: a or b | is array ? $ : ($ ? [$] : undefined)) More solutions:

  • a or b | is object ? [$] : $ or a or b | is not object ?: [$]
  • [...a or b].[] (creates temporary array)
  • a or b |? [...] or full form a or b | $ ? [...$] : $ (creates temporary array)

lahmatiy avatar May 16 '24 23:05 lahmatiy

Thanks, I think that will be enough for now.

obenjiro avatar May 17 '24 12:05 obenjiro