Defult value: {{list.selectedRows. where role='edit'}}?

My gold is so show selected values in a InputText65, InputText66, InputText67 field

Field 1

Field 2

Field 3

Is there a way to show the selection in text fields?

And is there anyone that can help a new beginner with a code?

-Thore

Hello!

In your Default value fields, is list a table?

If so, you want to filter the list table data by the role field?

Then, the code should look a little more like:

{{list.selectedRows.filter(row => row.role === 'viewer')}}

In order for this to display readably in a text field, you may want to also join the filtered list with commas by adding .join(", ") to the end:

{{list.selectedRows.filter(row => row.role === 'viewer').join(", ")}}

Hi @pyrrho

Thanks for your help. I tested your code, I did not get it to work.

My example:

Gold is to show the names in the textInput based on selections in the table.

Result will be this:

I added your code:
image
image
image

Can you help me with some code so I get this to work?

In advance thank you for your time.
-Thore

No problem!

{{ formatDataAsObject(table23.selectedRows.filter(row => row.role === 'Admin')).name.join(", ") }}

Since this is a text input you are using, you'll need to provide a string instead of an array. Since you are using an array of a whole objects with the filter, you only want a single property out of that object so we can format the resulting array as an object and pull out the names property (which will be an array again). Then, join the values of the array (the names we've collected) with a function to return a usable string:

2 Likes

Hi @pyrrho

Thanks for the code, it work as expected,

I get a error in the debug console: Cannot read properties of undefined (reading 'join')

I added a ? mark

{{ formatDataAsObject(table23.selectedRows**?**.filter(row => row.role === 'Admin')).name?.join(", ") }}

This removed the errors, I do not know it this is correct.

The ? is an optional chaining operator so it makes sense that if the table has no selected rows, the filter won't be used at all.