How to set TableColumn in Table using ForEach

         Table(tableData) {
          ForEach(tableColumns) { item in
            TableColumn(item.name) { data in
                  Text(data.value)
            }
          }
        }

What do you get ? What did you expect ?

The syntax includes a value:

struct Person: Identifiable {
  let givenName: String
  let familyName: String
  let id = UUID()
}

@State private var people = [
  Person(givenName: "Juan", familyName: "Chavez"),
  Person(givenName: "Mei", familyName: "Chen"),
  Person(givenName: "Tom", familyName: "Clark"),
  Person(givenName: "Gita", familyName: "Kumar"),
]

TableColumn("Given Name", value: \Person.givenName) { person in
    Text(person.givenName)
}

So you should likely have this:

            TableColumn(item.name, value : \.XXXXX.value) { data in
                  Text(data.value)
            }

where XXXX is the struct containing value.

So you should have something like:

          ForEach(tableColumns) { item in
            TableColumn(item.name, value : \.XXXXX.value) { data in
                  Text(data.value)
            }

This is a very essential question since it would give us the possibilities to show/hide table columns dynamically which is not possible another way.

So I am asking the same. Can someone provide a complete working solution ?

Having the same question, any ideas on this?

I have the same question.

Anybody find work solution?

How to set TableColumn in Table using ForEach
 
 
Q