# Support for dynamic column settings

**URL:** <https://resource.dopus.com/t/support-for-dynamic-column-settings/26344>\
**Category:** Help & Support\
**Created:** [July 11, 2017, 10:38am UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344 "2017-07-11T10:38:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 11, 2017, 10:38am UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/1 "2017-07-11T10:38:34Z")

</div>

Hello Dopus'ers,

I would like to suggest an extension to the **ScriptColumn** feature. Being able to dynamically assign configuration values.

There are a few **ScriptColumn** that have been created that contain configuration on a per column basis. For example one of the many regexp columns [regex columns reloaded](https://resource.dopus.com/t/regexcolumnsreloaded-easily-add-regex-columns-or-any-kind-of-column/20799), and [custom-text](https://resource.dopus.com/t/custom-column-custom-text-v1-2/18727). These scrips are all configurable in that extra custom columns can be added by editing the script config, often stored in the script file.

There are also some columns like the [newest file](https://resource.dopus.com/t/custom-column-newest-file/18765), and [newest file with filtering](https://resource.dopus.com/t/custom-column-newest-file/18765). Where there are many similar columns with slightly different settings.

Adding a new type of ScriptColumn that supported assigning configuration values would make these easier to create in a flexible way and easier to use. The column could be configured via customised [Script Dialogs](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Script_Dialogs1.htm).

For example the user selects the **newest file** column. They display the columns **script dialog** , where they select recursive and some other setting, like a filter and how to output the results.

Or I might add two regexp columns and similarly configure them as needed. Displaying columns **script dialog** and entering the regexp and other settings.

Thoughts?

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 11, 2017, 11:22am UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/2 "2017-07-11T11:22:18Z")

</div>

I think configuring script columns at the moment you turn them on (vs configuring which columns the script provides in advance, e.g. from the script's Config dialog) would make things complicated for both users and script authors.

It needs to be possible to turn columns on and off (without a dialog appearing every time) via commands. The commands would need a way to pass the custom configuration to the script in text format, and the user and script would need a way to get the text version of the configuration.

When config wasn't passed, I think this idea would end up triggering a dialog in unexpected places.

You might be able to make a script that has a toolbar button (or menu item etc.) you can click to add new columns. That could show a custom dialog, then save the details of the column, add the column to Opus (via [Script.InitColumns](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Script.htm)), and even turn the column on as the last step. I think that would be a better way to do what you're looking for.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 16, 2017, 1:54am UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/3 "2017-07-16T01:54:06Z")

</div>

Having a button to configure the columns as you describe is nice plan. Will take look at the CustomDialog functionality see what I can get going.

That style of dialog might also be useful for other scrips like the [external compare tools](https://resource.dopus.com/t/external-compare-and-merge-tools-2-0/18570/14) script. Where there is large blocks of config that the user might like to edit or extend.

Thanks for the input.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 17, 2017, 11:02am UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/4 "2017-07-17T11:02:18Z")

</div>

I had some success getting this to work.  
I adapted a script that supports custom [xml-and-xpath-columns](https://resource.dopus.com/t/column-xml-and-xpath-columns/26351). I moved the column config from being hard coded in the script to a [script-defined variable](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Vars.htm). I would have preferred using the [ScriptConfig](https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/ScriptConfig.htm) but I think this is readonly to the script?

This dialog configures the columns, it is triggered by a button. The **Apply Changes** button saves the changes (to a variable) and triggers a refresh of the \*\* custom column\*\*. This makes testing column configurations pretty easy.  
 ![](https://resource.dopus.com/uploads/default/original/3X/5/9/59b6962cbe56c95cbca777f0960d7ecbdf9602ed.jpg)

This button displays the above dialog.

```auto
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Xml</label>
	<icon1>#XmlColumns:XmlBlue</icon1>
	<function type="normal">
		<instruction>XmlColumnsConfigure</instruction>
	</function>
</button>
```

[XmlColumns.osp](https://resource.dopus.com/uploads/default/original/3X/2/f/2ffc4f777cb642e5ce9568337ef96295c8c2c7dc.osp) (12.3 KB)

If you would like to test try this xml and the.

- xpath .//\*[1]
- will match the amount
- xpath .//\*[2]
- will match the date

```auto
<?xml version="1.0" encoding="UTF-8"?>
<note>
  <amount>50</amount>
  <date>2017-12-13</date>
</note>
```

feedback welcome.

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [July 18, 2017, 2:55pm UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/5 "2017-07-18T14:55:15Z")

</div>

Pretty good from my point of view. o)

A little drawback is the lose coupling between a button somewhere and a mystic script variable.  
Well, the script var is not that mystic anymore once you know about it, but some people might wonder where their configuration is stored. It would be nice though, if a script could write into its own (or others) ScriptConfig items.

To get some tighter relation between script and button:  
The external toolbar button which brings up your custom dialog to edit the columns could also be launched by the "i" icon in the scripts section of the prefs (OnAbout() functionality), but the "i" is actually still not the right place. A custom "gear" icon in the script prefs to trigger custom config dialogs would be best. o)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 18, 2017, 4:14pm UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/6 "2017-07-18T16:14:00Z")

</div>

> [@tbone](#):
>
> A little drawback is the lose coupling between a button somewhere and a mystic script variable.  
> Well, the script var is not that mystic anymore once you know about it, but some people might wonder where their configuration is stored. It would be nice though, if a script could write into its own (or others) ScriptConfig items.

To a user, it won't matter if the config is stored in a ScriptConfig object or a Var object. It's all mystic behind-the-scenes details that they won't even be aware of.

Allowing scripts to display their own dialogs in place of the generic script config dialog might make sense, though. I think we'd need to see more than one script that could benefit from it for it to be worth implementing, but it's something we should keep in mind and is certainly a good idea.

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 18, 2017, 6:15pm UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/7 "2017-07-18T18:15:10Z")

</div>

> [@tbone](#):
>
> but some people might wonder where their configuration is stored.

I agree, which is why i created this [global-variable-management-dialog](https://resource.dopus.com/t/global-variable-management-dialog/26402). I will need to include some instructions as to where it is. Maybe add the name of the var as ScriptConfig.

> [@tbone](#):
>
> It would be nice though, if a script could write into its own (or others) ScriptConfig items.

Agreed. Also I wanted to allow someone to edit the config without the dialog if they wanted. But the Dialog works so well I am not sure its needed, I would not bother.

@Leo, is right it does not matter to the user. Still having all the config in the same place as the other config makes sense, if someone goes looking for it.

> [@Leo](#):
>
> Allowing scripts to display their own dialogs in place of the generic script config dialog might make sense, though.

This dialog does not edit all the config, only what is specific to the columns. I think I would rather allow the dialog to display from the default config, not instead of.

> [@Leo](#):
>
> I think we'd need to see more than one script that could benefit from it for it to be worth implementing, but it's something we should keep in mind and is certainly a good idea.

I have ideas for a couple more 🙂

---

<div class="post-metadata">

**Author:** ![wowbagger](https://resource.dopus.com/user_avatar/resource.dopus.com/wowbagger/32/25880_2.png) [@wowbagger](https://resource.dopus.com/u/wowbagger)\
**Post date:** [July 19, 2017, 1:42pm UTC](https://resource.dopus.com/t/support-for-dynamic-column-settings/26344/8 "2017-07-19T13:42:57Z")

</div>

Building on an [older](https://resource.dopus.com/t/custom-column-custom-text-v1-2/18727) script, a similar dialog for creating regexp columns.  
Its still a work in progress, but gives an idea.

feedback welcome.

 ![](https://resource.dopus.com/uploads/default/original/3X/c/3/c32c830ea94bdb989d31a492f346b75fc934cd93.jpg)

Button for dialog

```auto
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>RegExp </label>
	<tip>Manage RegExp Columns</tip>
	<icon1>#RegExpColumns:RegExpBlue</icon1>
	<function type="normal">
		<instruction>RegExpColumnsConfigure</instruction>
	</function>
</button>
```

[RegExpColumns.osp](https://resource.dopus.com/uploads/default/original/3X/b/7/b73a8c71e00a7bbb012be190f80a30ee337c050f.osp) (31.6 KB)
