# How to query Database Table to populate Power Table Drop Down List within cell

**URL:** <https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614>\
**Category:** Ignition\
**Tags:** scripting, database, ignition79\
**Created:** [August 20, 2019, 11:25pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614 "2019-08-20T23:25:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [August 20, 2019, 11:25pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/1 "2019-08-20T23:25:38Z")

</div>

I have used the extension function configureEditor to script defined drop down boxes within Power Tables before. Now I would appreciate some help using a database table query to populate the drop down cell.

I have read most of the related forum articles but I am still struggling. I am a rookie so I could really use some very specific scripting help.

My database table I want to query titled shift.  
The column i would like the query drop down to be in is labeled name.

Believe me when I say your help is appreciated.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [August 26, 2019, 7:42pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/2 "2019-08-26T19:42:02Z")

</div>

I am all perspective. So I don’t know if this helps or not.

But, I populate dropdowns with a named query or a query tag

`SELECT part_code as 'value', part_type as 'label' FROM mes.lot_size;`

then write that to the options props with binding.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [August 27, 2019, 7:08pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/3 "2019-08-27T19:08:16Z")

</div>

I didn’t explain well enough, sorry.  
I’m wanting to use the Power Table’s Component Scripting - configureEditor to create a Drop Down List within the same Power Table. This Power Table Cell Drop Down list would be populated by a Querying a data base table. We’re using Version 7.9.4

---

<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:** [August 27, 2019, 7:17pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/4 "2019-08-27T19:17:49Z")

</div>

Check out my post here:

> [@Force configure cell update in power table](http://forum.inductiveautomation.com/t/force-configure-cell-update-in-power-table/16318/7):
>
> The much more efficient solution is to embed a custom editor, which will lookup the datasets dynamically whenever it’s appropriate. I’ve got a very simple example of this below; the project has an editable ‘Options’ dataset, and the available options in column B in the editable table will be dynamic based on the value in column A. The relevant code is here: root = self from javax.swing import JComboBox, DefaultCellEditor, DefaultComboBoxModel class CustomCellEditor(DefaultCellEditor):…

Basically the same procedure would apply, except instead of fetching the options from another component, you would run your query. I would suggest putting your query onto a custom property on the power table - that way: 1. it's easier to control the polling rate, and 2. you don't ever run into a situation where your power table totally fails to render if a query times out or something else happens.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2019, 7:22pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/5 "2019-08-27T19:22:09Z")

</div>

> [@paul-griffith](#):
>
> you don’t ever run into a situation where your power table totally fails to render if a query times out or something else happens.

Yeah, you definitely do not want to be running queries within these editor (and/or renderer) subclasses. The custom property should hold all of the possible dropdown options for the entire table, and be filtered in the editor/renderer to the appropriate items when triggered.

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [August 28, 2019, 8:28pm UTC](https://forum.inductiveautomation.com/t/how-to-query-database-table-to-populate-power-table-drop-down-list-within-cell/27614/6 "2019-08-28T20:28:45Z")

</div>

This article helped us accomplish our goal using Power Table Cell drop Down List.

> [@Power Table Drop Down List with ability to enter new text?](http://forum.inductiveautomation.com/t/power-table-drop-down-list-with-ability-to-enter-new-text/12876):
>
> Using Ignition 7.9.0 on windows 7 x64 I have a power table that has a vendor column. What I’d like to do is give an authorized user the option of selecting from a list of existing vendors or just enter in their own. Right now, under the confgureEditor extension Functions I have the following code: [code] if colName == ‘vendor’: # Create a list of Areas and Bays via SQL Query query = “SELECT DISTINCT vendor FROM assets” vlist = system.db.runPrepQuery(query) #move the data into a python l…

 ![Power%20Table%20Drop%20Down%20List%20configureEditor%20Script](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/67a4c564e57386c7590d6ecc0fbd28aa060037b5.png)
