# Edit a cell in TableView

**URL:** <https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363>\
**Category:** General Usage\
**Tags:** question, webapps\
**Created:** [June 17, 2019, 11:11am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363 "2019-06-17T11:11:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 17, 2019, 11:11am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/1 "2019-06-17T11:11:54Z")

</div>

Say I have a table that I want to show from the REPL:

```julia
using Blink, TableView
n = 10
t = (id = 1:n, good = rand(Bool, n))
w = Blink.Window()
body!(w, showtable(t))

```

How exactly can I flip the true/false content in the cells (i.e. edit the contents of the cells), and then retrieve the new values?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 17, 2019, 11:20am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/2 "2019-06-17T11:20:42Z")

</div>

You can’t. 🙂  
It should be possible to do this for some tables, but the Tables.jl doesn’t support mutating tables yet, afaict.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 17, 2019, 11:21am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/3 "2019-06-17T11:21:32Z")

</div>

> [@pfitzseb](#):
>
> It should be possible to do this for some tables

Which ones? I can use those instead.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 17, 2019, 11:26am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/4 "2019-06-17T11:26:09Z")

</div>

A matrix or dataframe, for example. But as I said, Tables.jl doesn’t support mutating sources yet, so TableView.jl can’t either.  
@quinnj (or maybe @piever) probably knows how realistic it is to get that anytime soon.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 17, 2019, 11:32am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/5 "2019-06-17T11:32:25Z")

</div>

> [@pfitzseb](#):
>
> But as I said, Tables.jl doesn’t support mutating sources yet, so TableView.jl can’t either.

Ah… I thought you were referring to the fact that a named tuple such as the `typeof` `t` is considered a `Table.table`.

I see. Well, to be honest, I’m trying to avoid Gtk and use TableView as part of a UI. So perhaps not totally cosher to start with…

Thanks though!

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 17, 2019, 11:36am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/6 "2019-06-17T11:36:23Z")

</div>

It would be fairly trivial to do this for some tables, probably, but I’d really like to avoid special casing e.g. DataFrames (and depending on it, of course).

One thing we could also do is add a `callback` kwarg to `showtable`, which has the edited cell and the new value as its arguments. That would put the burden of figuring out how to mutate the table on you though 🙂

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [June 17, 2019, 11:38am UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/7 "2019-06-17T11:38:47Z")

</div>

> [@pfitzseb](#):
>
> It would be fairly trivial to do this for some tables, probably, but I’d really like to avoid special casing e.g. DataFrames (and depending on it, of course).

Yea, keep it lean.

> [@pfitzseb](#):
>
> One thing we could also do is add a `callback` kwarg to `showtable` , which has the edited cell and the new value as its arguments. That would put the burden of figuring out how to mutate the table on you though 🙂

Sounds like a reasonable solution… At the end of the day isn’t it a text dialog?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 17, 2019, 1:18pm UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/8 "2019-06-17T13:18:36Z")

</div>

[https://github.com/JuliaComputing/TableView.jl/pull/24](https://github.com/JuliaComputing/TableView.jl/pull/24)

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [June 17, 2019, 9:40pm UTC](https://discourse.julialang.org/t/edit-a-cell-in-tableview/25363/9 "2019-06-17T21:40:26Z")

</div>

Yeah, there’s an [open issue](https://github.com/JuliaData/Tables.jl/issues/11) about this for Tables.jl. Part of the issue is that there is indeed a ton of variability in terms of which tables could support this; pretty much only in-memory sources, which would exclude file formats (feather, csv), most databases (sqlite, mysql, odbc), so it just hasn’t felt like a high priority given this would be exclusively for in-memory structures.

There was talk at one point of possibly enhancing or creating a new ` InMemoryTable` interface that could add additional features like: mutability, requiring `getindex` and iteration on rows, etc.
