# Delete a row from Ui-table

**URL:** <https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973>\
**Category:** Dashboard\
**Created:** [29 January 2021 04:23 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973 "2021-01-29T04:23:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kushal](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kushal](https://discourse.nodered.org/u/Kushal)\
**Post date:** [29 January 2021 04:23 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973/1 "2021-01-29T04:23:33Z")

</div>

Hello! I wanted to know how can we delete a row from the UI-table widget just by clicking on it OR by any other way.  
I don't want to bodge! I have made it work by deleting the entire data and then adding the new data without that particular row. But I think its a suboptimal solution. I believe there's a simpler and better way to do it.

I use the following structure to add a row into the ui-table. Perhaps something similar for deleting a single row?

```auto
msg.payload = {
    command: "addRow",
    arguments: [
        {
            "Name": Rock
        },
        true
    ],
    returnPromise: true
}

```

**Is there a command for simply removing a row either by clicking on it or by matching a cell of that row?**

I am a complete newbie and thus I am facing difficulty in understanding the [Tabulator](http://tabulator.info/docs/4.4/update#retrieve-data) documentation.

Thanks! 😃

---

<div class="post-metadata">

**Author:** ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)\
**Post date:** [29 January 2021 06:15 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973/2 "2021-01-29T06:15:06Z")

</div>

Have you read this post (includes examples)? [Ui-table supports ui\_control - #49 by Christian-Me](https://discourse.nodered.org/t/ui-table-supports-ui-control/18870/49)

---

<div class="post-metadata">

**Author:** ![Christian-Me](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christian-me/32/10774_2.png) [@Christian-Me](https://discourse.nodered.org/u/Christian-Me)\
**Post date:** [29 January 2021 07:19 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973/3 "2021-01-29T07:19:03Z")

</div>

Hi,

In the documentation you find Javascript examples running in the browser. Node-RED runs on your server and communicates with the browser front end (dashboard). So you (the ui-table node for you) has to send a message from the runtime (back end) to the dashboard asking to execute a function call (command) for you.  
So the [command you find in the doc](http://tabulator.info/docs/4.7/update#alter-add):

```auto
table.deleteRow(15); //delete row with an id of 15
//or
table.deleteRow([15,7, 9]); //delete rows with ids of 15, 7 and 9

```

will translate into

```auto
msg.payload = {
    command: "deleteRow",
    arguments: [
        15
    ],
    returnPromise: true
}

```

or

```auto
msg.payload = {
    command: "deleteRow",
    arguments: [
        [15, 7, 9]
    ],
    returnPromise: true
}

```

so either one index or an array of indexes. By default the index is a column named `id`. So to use `deleteRow ` you should add this column to your data:

```auto
msg.payload = {
    command: "addRow",
    arguments: [
        {
           "id":15, 
           "Name": Rock
        },
        true
    ],
    returnPromise: true
}

```

with a unique index for each row. The index column don't has to be visible, don't has to be a number and [you could define the index column as you wish](http://tabulator.info/docs/4.9/data#row-index), for example by sending `msg.ui_control.tabulator.index="Name"` and then the command to delete your row would look like this:

```auto
msg.payload = {
    command: "deleteRow",
    arguments: [
        "Rock"
    ],
    returnPromise: true
}

```

Or as @Bobo mentioned try my subfow. There you have to define an index column in the node configuration.

If something is not working as expected take a look in the browser console, not the Node-RED editor debug tab as the commands are finally executed in the browser context.

Have fun 😉

---

<div class="post-metadata">

**Author:** ![Kushal](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kushal](https://discourse.nodered.org/u/Kushal)\
**Post date:** [30 January 2021 16:48 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973/4 "2021-01-30T16:48:01Z")

</div>

Thanks a lot! It's working!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 February 2021 16:48 UTC](https://discourse.nodered.org/t/delete-a-row-from-ui-table/39973/5 "2021-02-13T16:48:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
