kuehne
kuehne

Reputation: 57

How to display selection according to the condition ? (element-ui table)

I have a problem. I want to display selection according to the condition.

Here is the example. I want to hide the selection for the name 'Jeff'

http://jsfiddle.net/8y5cnk1p/2/

If I try to use 'v-if'

<el-table-column type="selection" width="45" v-if="name != 'Jeff'" &nbsp;</el-table-column>

It doesn't work. How?

Thanks!

Upvotes: 2

Views: 7708

Answers (2)

Zoe
Zoe

Reputation: 140

You can display the column of checkbox.

<el-table-column
  v-if="isShow"
  :key="Math.random()"
  type="selection"
  width="45">
</el-table-column>

Don't forget the "key" !!!

Upvotes: 0

Styx
Styx

Reputation: 10076

You can't hide the checkbox, but you can disable it using selectable attribute:

<el-table-column type="selection"
                 width="45"
                 :selectable="canSelectRow">
</el-table-column>
methods: {
  canSelectRow(row, index) {
    return row.name !== 'Jeff';
  }
}

Docs: Table Column Attributes

Upvotes: 8

Related Questions