Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TrevorNWatson's avatar

Displaying a property in an array found by id

We are currently trying to retrieve a property and display a checkbox based on an property inside of an array.

For example:

[
 {
    member: 10,
    locations: [
      { 
        location: 50063, 
        approved: true
      },
      { 
        location: 20063, 
        approved: false
      }
    ]
 }
]

And using el-table

<el-table :data="members">
  <el-table-column label="INACTIVE/ACTIVE">
    <template scope="scope">
      <input type="checkbox" ***SOMETHING GOES HERE*** v-on:click="handleUserActivation(scope.row)">
    </template>
  </el-table-column>
</el-table>

Things I've found

  • It can't be a computed property as we can't determine the row that we're on and return the proper value
  • It can't be a v-model since the value doesn't seem to be on the list.

I had PARTIAL success in using a computed method and putting it in as a formatter

 getState(row, column, cellValue) {
        console.log(row);
        return row.locations.find(function(c) { return c.location== localStorage.getItem("currentLocation") }).approved.toString();
      }

But this seems to only work if I'm returning the string (toString)

Is it possible to find a boolean property in an array in an el-table and use it for a checkbox?

Alternatively, I'll have to create a property on the objects and populate that when I populate the collection and then use that value maybe?

Thanks in advance,

0 likes
0 replies

Please or to participate in this conversation.