# Insert & Update functionality for Power table (Without Button)

**URL:** <https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 10, 2023, 9:47am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893 "2023-03-10T09:47:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kuldeep\_Pawar](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kuldeep_pawar/32/44736_2.png) [@Kuldeep\_Pawar](https://forum.inductiveautomation.com/u/Kuldeep_Pawar)\
**Post date:** [March 10, 2023, 9:47am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/1 "2023-03-10T09:47:45Z")

</div>

Hello All,

I am getting data into power table through SQL query from a particular table. However I want to give insert & update functionality in this power table.  
**Update operation** : User will click on any cell in power table & edit that particular cell & press enter. That entry should be updated in SQL table.  
**Insert operation** : For this, I want to give one blank row at the end of the power table where user will enter all the details & press enter. That entry should be inserted in SQL table.

Please suggest me how can we achieve this. If not then any alternative for this.

Thanks in advance!!

-- KD

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 10, 2023, 10:11am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/2 "2023-03-10T10:11:03Z")

</div>

Put all of your query logic in the power table's onCellEdited extension function.

To separate your blank row insert statement from your update statements simply qualify it with something like:

```auto
if rowIndex == (self.data.rowCount - 1):
# Insert Statement Here
else:
# Update Statement Here

```

You can modify your query that populates the table to include a blank row, and then refresh the table after each update or insert query has completed

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [March 12, 2023, 9:03am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/3 "2023-03-12T09:03:58Z")

</div>

@justinedwards.jle Thanks for your help.

Can you suggest how to add a blank row to the power table? and also delete the selected row functionality for the power table without a button.

I really appreciate any help you can provide.  
Priyanka Khandge

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 12, 2023, 9:44am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/4 "2023-03-12T09:44:09Z")

</div>

> [@Priyanka.Khandge](#):
>
> how to add a blank row

I would set the query to include the blank row. For a simplified example look at this SQL Fiddle I threw together:

> **[SQL Fiddle | A tool for easy online testing and sharing of database problems...](http://sqlfiddle.com/#!9/37bd325/2)**
>
> Application for testing and sharing SQL queries.

Notice how the result includes a blank row at the end.  
`#========================`

> [@Priyanka.Khandge](#):
>
> delete the selected row functionality

I'm not sure what you mean by this, but the selection behavior is set by the following two properties:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f04b450bd7e37350628ccc104fa3cf0c192f915b.png)

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [March 12, 2023, 10:41am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/5 "2023-03-12T10:41:43Z")

</div>

@justinedwards.jle Thanks for the quick response.

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

As you suggest black row was added successfully but the row height not showing properly.

Any idea for that?

Many thanks for considering my request.

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [March 12, 2023, 10:49am UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/6 "2023-03-12T10:49:16Z")

</div>

Thanks, @justinedwards.jle.

I got the answer, Set row height using the **Auto Row Height** property. set this property to false.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/02ecfe6f4de72d177fbcd87c9521272e581af8a1.png)

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [March 12, 2023, 12:47pm UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/7 "2023-03-12T12:47:25Z")

</div>

Hi @justinedwards.jle,

I have tried to insert and update the row using onCellEdited. The updated row successfully works but the insert row does not work.

Any Idea?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/8633047c2d6c715c43e9509e37a021818ca7b0b7.png)

Thanks  
Priyanka

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 12, 2023, 12:58pm UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/8 "2023-03-12T12:58:32Z")

</div>

Your SQL server is throwing the exception. There must be a syntax error of some kind. Which SQL server are you using? ...and could you do me a favor and copy your query and paste it into the forum using "```" on either side of it? It will look like:

```auto
Insert into [...] values [...]

```

It will make it easier for me to accurately replicate the problem.

**Additional note:**  
I typically troubleshoot problems of this nature by testing the query directly in the database. A lot of times a red squiggly line there will tell me the problem with my syntax:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/761a1864d0564a7872d722374c9c09bc16c48b1a.png)

---

<div class="post-metadata">

**Author:** ![Priyanka.Khandge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/priyanka.khandge/32/35989_2.png) [@Priyanka.Khandge](https://forum.inductiveautomation.com/u/Priyanka.Khandge)\
**Post date:** [March 12, 2023, 1:31pm UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/9 "2023-03-12T13:31:41Z")

</div>

@justinedwards.jle Thanks for your help.

I got my SQL query error. Currently, insert a row but if I enter any value in the last row then immediately open both popup insert and update. I required when I enter a new value in the last row then only open the insert popup.

and another one I face an error when I enter any value in a single row and then immediately automatically enter the same value in all rows.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/8/78fbf44cb1a6904457c327606217ddec86556051.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 12, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/insert-update-functionality-for-power-table-without-button/70893/10 "2023-03-12T13:50:47Z")

</div>

I'm afraid I'm going to be offline for the next few hours, but looking at what I can see of your code, you are calling your custom method from the onCellEdited extension function and passing in the new value from a single cell. My guess is that you are attempting to insert in all four columns, but you are not getting the values from the surrounding cells using the row index. It would be something like:

```auto
valueZero = self.parent.getComponent('NumericTextFieldLfdNummer').floatValue
valueOne = newValue if colIndex == 1 else self.data.getValueAt(rowIndex, 1)
valueTwo = newValue if colIndex == 2 else self.data.getValueAt(rowIndex, 2)
valueThree = newValue if colIndex == 3 else self.data.getValueAt(rowIndex, 3)

#[...]

insertArgs = [valueZero, valueOne, valueTwo, valueThree]

```

Also, and this is where it would get tricky, I can imagine that you will need something in your onCellEdited call that prevents the insert if there are null values in any of the surrounding columns.

Anyway, it's an interesting problem, so I'm curious about the final result. I'll be sure to check back in on this later in the day.
