# Tag Browser in a Window

**URL:** <https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574>\
**Category:** Ignition\
**Created:** [June 5, 2012, 2:09pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574 "2012-06-05T14:09:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomt](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tomt](https://forum.inductiveautomation.com/u/tomt)\
**Post date:** [June 5, 2012, 2:09pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/1 "2012-06-05T14:09:56Z")

</div>

I wanted a quick way to show tags in a project, without adding a ton of labels. I know I can drag and drop tags to a window and create a control, but I wanted the name too.

I came up with this: use a tree view to show the tag database, bind it to a tableview to show the tags and values.

1. Create a tree view. Populate it with this SQL. Set the FROM clause accordingly

```auto
SELECT path,name as text,'' as selectedtext
  FROM [ignTest].[dbo].[sqlt_core]
  where tagtype=6 and deleted=0
group by path,name
  order by path,name
```

1. Create a list view - add a custom property called ‘path’ and bind it to the selectedPath of the tree view

2. use this SQL in the list view:

`SELECT
name,
CASE datatype
	when 0 then 'Int1'
	when 1 then 'Int2'
	when 2 then 'Int4'
	when 3 then 'Int8'
	when 4 then 'Float4'
	when 5 then 'Float8'
	when 6 then 'Boolean'
	when 7 then 'String'
	when 8 then 'DateTime'
	when 9 then 'DataSet'
end as Type,
CASE datatype
	when 0 then convert(varchar,intvalue)
	when 1 then convert(varchar,intvalue)
	when 2 then convert(varchar,intvalue)
	when 3 then convert(varchar,intvalue)
	when 4 then convert(varchar,floatvalue)
	when 5 then convert(varchar,floatvalue)
	when 6 then convert(varchar,intvalue)
	when 7 then convert(varchar,stringvalue)
	when 8 then convert(varchar,datevalue)
	when 9 then 'na' 
end as Value,
--valuechange,
case dataintegrity
	when 192 then 'Good'
	else 'Not Good'
end as Integrity
FROM [ignTest].[dbo].[sqlt_core]
where path = '{Root Container.Tree View.selectedPath}'+'/'
	and deleted=0
	and tagtype in (0,1)
`

Note that not all cases are handled, and this works for me. I just didn’t see anything quite like it when I was looking for this. I’m also thinking of using this as a way to get a trend of any point in the system, as I can trigger an event on the table view to bring up a pop up of the graph.

Enjoy!

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/607510a3dc12b5db82ce40014da85ba77258c7bc.jpg)

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [June 5, 2012, 2:52pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/2 "2012-06-05T14:52:27Z")

</div>

This looks pretty cool Tom.

I have to think abit on it, but I think I can turn this idea into a bulk edit screen 😉

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 5, 2012, 5:34pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/3 "2012-06-05T17:34:02Z")

</div>

Nice

---

<div class="post-metadata">

**Author:** ![tomt](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tomt](https://forum.inductiveautomation.com/u/tomt)\
**Post date:** [June 5, 2012, 6:28pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/4 "2012-06-05T18:28:02Z")

</div>

Add pop-up Trend:

1. Create a pop window
2. add two custom string properties on the root container: tagpath and tagname
3. add an easychart
4. use a SQL query on the Tag Pens property and use this code:

```auto
SELECT '['+meta.stringval+']'+path+core.name as tag_path,
	core.name
FROM sqlt_core as core
left join sqlt_meta as meta
on core.id=meta.tagid and meta.name='PrimaryHistoryProvider'
WHERE path = '{Root Container.tagpath}'+'/'
and core.name = '{Root Container.tagname}'
and deleted=0
and enabled=1
```

Go back to your table in the tag browser window and add this to the mouseClicked event. I chose a double click to open a trend.

```auto
if event.clickCount == 2:
	r = event.source.selectedRow
	if r >= 0:
		tagname = event.source.data.getValueAt(r, "name")
	system.nav.openWindow('Popups/PopupTrend', {'tagname' : tagname,'tagpath':event.source.path})
```

Modify paths and names of windows accordingly.

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [June 5, 2012, 6:32pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/5 "2012-06-05T18:32:49Z")

</div>

All great information! However, this should probably be posted in the “User Submitted Content” section of the forums.

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [June 6, 2012, 3:18pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/6 "2012-06-06T15:18:21Z")

</div>

I was thinking that too. Can you move this thread there?

Edit: I see it’s been moved.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [June 7, 2012, 7:14pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/7 "2012-06-07T19:14:50Z")

</div>

Is it work with internal tag or only with external source ?  
Is it possible to access to sql\_core table (for internal tag) with the sql query script function ?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [June 8, 2012, 3:03pm UTC](https://forum.inductiveautomation.com/t/tag-browser-in-a-window/4574/8 "2012-06-08T15:03:01Z")

</div>

Right now it is not possible to access tags stored in the internal database.
