# \[FEATURE\] Context menu option to add all columns from data into Table props.columns

**URL:** <https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 24, 2023, 12:27am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800 "2023-04-24T00:27:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 24, 2023, 12:27am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800/1 "2023-04-24T00:27:32Z")

</div>

Often I will want to add all or most columns from a Table's data into the `props.columns` array and configure them, however every time I have to add them manually. It would be nice if there was a context option (similar to embedded view params) to add all columns from the data.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 24, 2023, 6:32am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800/2 "2023-04-24T06:32:02Z")

</div>

In the meantime, you could add a function to your library that you would use in a script transform to populate the columns. When it's populated, remove the binding and you're done.

It's a bit more steps than a built-in functionality, but while waiting for it to be implemented... it can save you some time.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 24, 2023, 11:35am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800/3 "2023-04-24T11:35:35Z")

</div>

Yeah, that's what I ended up doing and I saved it for future use. I was going to post it but got carried away working 😅

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 25, 2023, 2:56am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800/4 "2023-04-25T02:56:48Z")

</div>

Here it is, in case it's useful to anyone:  
Just copy the json, paste it to the binding of the `props.columns`, then remove it. It'll create items in `props.columns` for each field in the `props.data`

```auto
{
  "type": "property",
  "enabled": false,
  "config": {
    "path": "this.props.data"
  },
  "transforms": [
    {
      "code": "\td \u003d {\n\t \"field\": \"\",\n\t \"visible\": True,\n\t \"editable\": False,\n\t \"render\": \"auto\",\n\t \"justify\": \"auto\",\n\t \"align\": \"center\",\n\t \"resizable\": True,\n\t \"sortable\": True,\n\t \"sort\": \"none\",\n\t \"filter\": {\n\t \"enabled\": False,\n\t \"visible\": \"on-hover\",\n\t \"string\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t },\n\t \"number\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t },\n\t \"boolean\": {\n\t \"condition\": \"\"\n\t },\n\t \"date\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t }\n\t },\n\t \"viewPath\": \"\",\n\t \"viewParams\": {},\n\t \"boolean\": \"checkbox\",\n\t \"number\": \"value\",\n\t \"progressBar\": {\n\t \"max\": 100,\n\t \"min\": 0,\n\t \"bar\": {\n\t \"color\": \"\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"track\": {\n\t \"color\": \"\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"value\": {\n\t \"enabled\": True,\n\t \"format\": \"0,0.##\",\n\t \"justify\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t }\n\t },\n\t \"toggleSwitch\": {\n\t \"color\": {\n\t \"selected\": \"\",\n\t \"unselected\": \"\"\n\t }\n\t },\n\t \"nullFormat\": {\n\t \"includeNullStrings\": False,\n\t \"strict\": False,\n\t \"nullFormatValue\": \"\"\n\t },\n\t \"numberFormat\": \"0,0.##\",\n\t \"dateFormat\": \"YYYY-MM-DD HH:mm:ss\",\n\t \"width\": \"\",\n\t \"strictWidth\": False,\n\t \"style\": {\n\t \"classes\": \"\"\n\t },\n\t \"header\": {\n\t \"title\": \"\",\n\t \"justify\": \"left\",\n\t \"align\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"footer\": {\n\t \"title\": \"\",\n\t \"justify\": \"left\",\n\t \"align\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t }\n\t}\n\tc \u003d []\n\timport copy\n\tfor col in value.columnNames:\n\t\tdd \u003d copy.deepcopy(d)\n\t\tdd[\u0027field\u0027] \u003d col\n\t\tc.append(dd)\n\treturn c",
      "type": "script"
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 25, 2023, 8:30am UTC](https://forum.inductiveautomation.com/t/feature-context-menu-option-to-add-all-columns-from-data-into-table-props-columns/72800/5 "2023-04-25T08:30:26Z")

</div>

This works only on datasets.  
Here's a quick modification to also handle arrays of objects (like the default values when you pull out a table):

json:

```json
{
  "type": "property",
  "config": {
    "path": "this.props.data"
  },
  "transforms": [
    {
      "code": "\timport copy\n\tfrom com.inductiveautomation.ignition.common import BasicDataset\n\td \u003d {\n\t \"field\": \"\",\n\t \"visible\": True,\n\t \"editable\": False,\n\t \"render\": \"auto\",\n\t \"justify\": \"auto\",\n\t \"align\": \"center\",\n\t \"resizable\": True,\n\t \"sortable\": True,\n\t \"sort\": \"none\",\n\t \"filter\": {\n\t \"enabled\": False,\n\t \"visible\": \"on-hover\",\n\t \"string\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t },\n\t \"number\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t },\n\t \"boolean\": {\n\t \"condition\": \"\"\n\t },\n\t \"date\": {\n\t \"condition\": \"\",\n\t \"value\": \"\"\n\t }\n\t },\n\t \"viewPath\": \"\",\n\t \"viewParams\": {},\n\t \"boolean\": \"checkbox\",\n\t \"number\": \"value\",\n\t \"progressBar\": {\n\t \"max\": 100,\n\t \"min\": 0,\n\t \"bar\": {\n\t \"color\": \"\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"track\": {\n\t \"color\": \"\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"value\": {\n\t \"enabled\": True,\n\t \"format\": \"0,0.##\",\n\t \"justify\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t }\n\t },\n\t \"toggleSwitch\": {\n\t \"color\": {\n\t \"selected\": \"\",\n\t \"unselected\": \"\"\n\t }\n\t },\n\t \"nullFormat\": {\n\t \"includeNullStrings\": False,\n\t \"strict\": False,\n\t \"nullFormatValue\": \"\"\n\t },\n\t \"numberFormat\": \"0,0.##\",\n\t \"dateFormat\": \"YYYY-MM-DD HH:mm:ss\",\n\t \"width\": \"\",\n\t \"strictWidth\": False,\n\t \"style\": {\n\t \"classes\": \"\"\n\t },\n\t \"header\": {\n\t \"title\": \"\",\n\t \"justify\": \"left\",\n\t \"align\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t },\n\t \"footer\": {\n\t \"title\": \"\",\n\t \"justify\": \"left\",\n\t \"align\": \"center\",\n\t \"style\": {\n\t \"classes\": \"\"\n\t }\n\t }\n\t}\n\theaders \u003d value.columnNames if isinstance(value, BasicDataset) else value[0].keys()\n\tc \u003d []\n\tfor col in headers:\n\t\tdd \u003d copy.deepcopy(d)\n\t\tdd[\u0027field\u0027] \u003d col\n\t\tc.append(dd)\n\treturn c",
      "type": "script"
    }
  ]
}

```

> **Here's the transform code:**
>
> ```python
> import copy
> from com.inductiveautomation.ignition.common import BasicDataset
> d = {
> "field": "",
> "visible": True,
> "editable": False,
> "render": "auto",
> "justify": "auto",
> "align": "center",
> "resizable": True,
> "sortable": True,
> "sort": "none",
> "filter": {
> "enabled": False,
> "visible": "on-hover",
> "string": {
> "condition": "",
> "value": ""
> },
> "number": {
> "condition": "",
> "value": ""
> },
> "boolean": {
> "condition": ""
> },
> "date": {
> "condition": "",
> "value": ""
> }
> },
> "viewPath": "",
> "viewParams": {},
> "boolean": "checkbox",
> "number": "value",
> "progressBar": {
> "max": 100,
> "min": 0,
> "bar": {
> "color": "",
> "style": {
> "classes": ""
> }
> },
> "track": {
> "color": "",
> "style": {
> "classes": ""
> }
> },
> "value": {
> "enabled": True,
> "format": "0,0.##",
> "justify": "center",
> "style": {
> "classes": ""
> }
> }
> },
> "toggleSwitch": {
> "color": {
> "selected": "",
> "unselected": ""
> }
> },
> "nullFormat": {
> "includeNullStrings": False,
> "strict": False,
> "nullFormatValue": ""
> },
> "numberFormat": "0,0.##",
> "dateFormat": "YYYY-MM-DD HH:mm:ss",
> "width": "",
> "strictWidth": False,
> "style": {
> "classes": ""
> },
> "header": {
> "title": "",
> "justify": "left",
> "align": "center",
> "style": {
> "classes": ""
> }
> },
> "footer": {
> "title": "",
> "justify": "left",
> "align": "center",
> "style": {
> "classes": ""
> }
> }
> }
> headers = value.columnNames if isinstance(value, BasicDataset) else value[0].keys()
> c = []
> for col in headers:
> dd = copy.deepcopy(d)
> dd['field'] = col
> c.append(dd)
> return c
> 
> ```

There might be other types to handle ? I don't know.
