# Perspective Tree

**URL:** <https://forum.inductiveautomation.com/t/perspective-tree/38504>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [September 9, 2020, 1:33am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504 "2020-09-09T01:33:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 9, 2020, 1:33am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/1 "2020-09-09T01:33:55Z")

</div>

I have a SQL table and used to populate a tree view in vision (for sake of this question I entered bogus data):

![treeVision](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/4/d43d0e4b194053794f24e40a47a8c5023e5a84d0.png)

Query:

```auto
SELECT a.id, `number` AS `text`, `number` AS `selectedText`, `name` AS `path` FROM tdssql.joblist a
INNER JOIN jobcustomer b ON a.custid = b.id
WHERE `name` LIKE '%{Root Container.txtlistJobsFilter.text}%' or 
`number` LIKE '%{Root Container.txtlistJobsFilter.text}%'

```

SQL table:

![JobSQL](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/d/3df95085bcf68a1f63f7e5bf91f17128d5622cc5.png)

In vision it was simple, but for the life of me I can’t seem to grasp the concept in Perspective. I’m assuming I will need a transform? Can anyone help me on this?

---

<div class="post-metadata">

**Author:** ![ali.khalil](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ali.khalil/32/18169_2.png) [@ali.khalil](https://forum.inductiveautomation.com/u/ali.khalil)\
**Post date:** [September 9, 2020, 1:53am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/2 "2020-09-09T01:53:51Z")

</div>

Hi there,

In perspective you need to call a named query.

In your case you have to create a named query with parameter “Filter” for instance.

Then you replace ‘%{Root Container.txtlistJobsFilter.text}%’ with :Filter, you can also use drag and drop.

When you call your query in perspective, you will see Filter under parameters. You can have it fixed value, expression or binding.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/3/c31e1e08c4c15790d1270a1828318992393bd956.png)

Please note I didn’t check query syntax, I am just showing a method.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 9, 2020, 2:10am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/3 "2020-09-09T02:10:15Z")

</div>

Yep, I’m actually using a named query in Vision, I just copied the query to show what I was doing. The same query doesn’t work across vision tree view and perspective tree view. All I will get is the labels or main folders. I’m guessing a transform is needed just not sure how to go about it.

Edit: This is what happens using the same query as in Vision:

![treePerspective](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/6/a63d312f4cbc9a94af394e66c12e622932067125.png)

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 9, 2020, 2:56am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/4 "2020-09-09T02:56:24Z")

</div>

Each object in the `props.items` array is formatted in a specific way to display the structure you are looking for.

For instance each item consists of

```auto
{
    "label": "My Item", 
    "expanded": False,
    "data": "1" #This can be anything, a string, list, dictionary, you name it,
    "items": []
}

```

Then if the item is a folder, it would contain more of that same structure inside the `items` array in that dictionary.

I went ahead and threw together a script that converts your query in a script transform, but you may need to play with it to get exactly what you’re looking for. This is with the named query output set to JSON in the binding

```auto
customers = []
items = []
for job in value:
    if job['custid'] not in customers:
        item = {
            "label": "Company #%s" % job['custid'],
            "expanded": True,
            "data": "",
            "items": [
                {
                    "label": job['number'],
                    "expanded": False,
                    "data": {
                        "jobID": job['id'],
                        "description": job['description']
                    },
                    "items": []
                }
            ]
        }
        customers.append(job['custid'])
        items.append(item)
    else:
        for index, customer in enumerate(customers):
            if customer == job['custid']:
                itemIndex = index

        item = {
            "label": job['number'],
            "expanded": False,
            "data": {
                "jobID": job['id'],
                "description": job['description']
            },
            "items": []
        }
        items[itemIndex]['items'].append(item)

return items

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 9, 2020, 11:55pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/5 "2020-09-09T23:55:51Z")

</div>

Perfect, thank you. I had to change a few things, but that was just what I needed. Much appreciated!!

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 10, 2020, 12:17am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/6 "2020-09-10T00:17:52Z")

</div>

Well, I spoke too soon. While it works, it is insanely slow. If I click on an item, it takes 2-5 seconds to react. I can tell something is going on since my laptop fan is on full afterburner. On a perspective table you can limit how many items are visible at a time, I guess there isn’t anything like that on the tree?

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 10, 2020, 3:31am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/7 "2020-09-10T03:31:07Z")

</div>

> [@jlandwerlen](#):
>
> I click on an item, it takes 2-5 seconds to react

This isn’t related to this binding, this would be an issue afterwards potentially due to the size of the data represented.

How many rows is your table starting out with? You may be loading in a really large amount of data that the tree just can’t render very well. There may be ways that it can be optimized depending on if that’s the cause or not

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 10, 2020, 1:09pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/8 "2020-09-10T13:09:00Z")

</div>

There’s only about 4000 rows. Throwing full rows into the vision component works very well. No lag at all.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 10, 2020, 2:48pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/9 "2020-09-10T14:48:51Z")

</div>

I think the speed issue you’re seeing is actually with the designer trying to render the item property array with a 4000 row object. Unfortunately the designer is not a fan of large properties, try putting it into a page and opening it in a client and see if that resolved the issue

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 10, 2020, 3:12pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/10 "2020-09-10T15:12:44Z")

</div>

The page never would load completely. I’ll give IA a call.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 10, 2020, 4:29pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/11 "2020-09-10T16:29:55Z")

</div>

On the vision tree view, if you type a letter the tree view will select a row with a name beginning with that letter. Is this functionality not supported in Perspective?

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [September 10, 2020, 6:21pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/12 "2020-09-10T18:21:15Z")

</div>

> [@jlandwerlen](#):
>
> The page never would load completely. I’ll give IA a call.

Definitely follow up here with the outcome if you can, I am curious whats causing it, and it may help others to know too.

> [@jlandwerlen](#):
>
> On the vision tree view, if you type a letter the tree view will select a row with a name beginning with that letter. Is this functionality not supported in Perspective?

This is actually something that isn't natively supported at this time due to the way that the tree is built. However it is something that I have started to pursue at the request of @nader.chinichian in this thread ([Perspective Progressive Tag Tree - #19 by miyanalu](http://forum.inductiveautomation.com/t/perspective-progressive-tag-tree/35495/19)) but Its still a work in progress.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 10, 2020, 7:18pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/13 "2020-09-10T19:18:52Z")

</div>

> [@kgamble](#):
>
> Definitely follow up here with the outcome if you can, I am curious whats causing it, and it may help others to know too.

You bet. Thanks for your help, it's much appreciated.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 2, 2020, 2:57pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/14 "2020-10-02T14:57:03Z")

</div>

I called IA and we discussed the tree component in Perspective. He had a good point on how to test, we bound to a query and used the transform. The speed was slow. We then unbound and the speed was the same. So, to us the speed issue wasn’t related to the query or transform, but just the amount of data. I could have typed the items in by hand and it would still behave the same.

I still think there is an issue, but at least I know it’s not the script or query.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [October 2, 2020, 3:26pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/15 "2020-10-02T15:26:12Z")

</div>

Did you ever try changing the access settings on the `props.items` for the tree?

I don’t remember exactly what to set it to, but I know @paul-griffith mentioned in another post (that I can’t find) that changing the access setting here can really help. Something about how the page loads the properties? He can probably clarify better

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 2, 2020, 3:36pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/16 "2020-10-02T15:36:12Z")

</div>

> [@kgamble](#):
>
> Did you ever try changing the access settings on the `props.items` for the tree?

I did not. I can wait for @paul-griffith to chime in. Right now access is set to Public and persistent is checked.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 2, 2020, 3:39pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/17 "2020-10-02T15:39:13Z")

</div>

Since you’re using it for the tree itself, changing property visibility to private isn’t an option; if private, it would never reach the front-end to be used for the tree’s actual rendering.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [October 2, 2020, 3:42pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/18 "2020-10-02T15:42:22Z")

</div>

Is there any special format you could use a dataset like in vision? Its unfortunate often times when the weight of the json structure being rendered in the designer makes large things like this often impossible. Datasets typically tend to let things load quite a bit faster

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 12, 2020, 9:55pm UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/19 "2020-11-12T21:55:36Z")

</div>

For what it’s worth, changes landed in today’s nightly (should make it into 8.1.1) that should _dramatically_ improve performance in the designer when interacting with large, complex JSON structures.

---

<div class="post-metadata">

**Author:** ![manjuyadav95.m](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@manjuyadav95.m](https://forum.inductiveautomation.com/u/manjuyadav95.m)\
**Post date:** [February 28, 2022, 9:46am UTC](https://forum.inductiveautomation.com/t/perspective-tree/38504/20 "2022-02-28T09:46:57Z")

</div>

It’s helped me as well thanks a lot…also plz confirm if adding script transform takes more time in execution than direct binding?

[Next page](https://forum.inductiveautomation.com/t/perspective-tree/38504.md?page=2)
