2
votes

To jump to the chase here is an example I made using bootstrap-vue's documentation to better explain the problem:

<template>
  <div>
    <div class="mb-2">
      <b-form-checkbox v-model="stickyHeader" inline>Sticky header</b-form-checkbox>
      <b-form-checkbox v-model="noCollapse" inline>No border collapse</b-form-checkbox>
    </div>
    <b-table
      :sticky-header="stickyHeader"
      :no-border-collapse="noCollapse"
      responsive
      :items="items"
      :fields="fields"
      head-variant="dark"
      striped
 >
      <!-- We are using utility class `text-nowrap` to help illustrate horizontal scrolling -->
      <template v-slot:head(id)="scope">
        <div class="text-nowrap">Row ID</div>
      </template>
      <template v-slot:head()="scope">
        <div class="text-nowrap">
          Heading {{ scope.label }}
        </div>
      </template>
    </b-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        stickyHeader: true,
        noCollapse: false,
        fields: [
          /* THIS IS THE LINE I CHANGE */
          { key: 'id', stickyColumn: true, variant: 'none'},
          'a',
          'b',
          'c',
          'd',
          'e',
          'f',
          'g',
          'h',
          'i',
          'j',
          'k',
          'l'
        ],
        items: [
          { id: 1, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 2, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 3, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 4, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 5, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 6, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 7, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 8, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 9, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 },
          { id: 10, a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6, h: 7, i: 8, j: 9, k: 10, l: 11 }
        ]
      }
    }
  }
</script>

I have taken this straight from the bootstrap-vue documentation here, with a few small mods. I changed the head-variant to "dark" (not default), and I made the table striped. with the sticky column, I have tried 3 different things:
1.

{ key: 'id', stickyColumn: true, variant: 'none'} // note 'none' is not actually a variant

2.

{ key: 'id', stickyColumn: true, variant: 'secondary'}

3.

{ key: 'id', stickyColumn: true}

Problems with each variations:
1. sticky column is treated as transparent and causes ugly overlapping of columns
2. I would like to maintain the striped pattern and not resort to a mono-toned background
3. for some reason the header-variant of the column changes back to the default

Goal:
I would like something that maintains the dark-header, but has the column style of 3.

Thanks for any help.

1

1 Answers

0
votes

I had the same issue and solved overwriting these css classes:

  td.b-table-sticky-column {
    background-color: inherit;
  }

  .table-striped tbody tr:nth-of-type(odd) {
      background-color: #f0f0f1!important; /* ~ RGBA(0,0,0,.5) on RGB */
  }
  
  .table-striped tbody tr{
    background-color: #ffffff!important;
  }

Then the background-color for the column assumes the background color from the striped row.

I was using table-light, but just replace for that one you're using.