1.0.3 • Published 4 years ago

ex-tablewjw v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

ex-table-column

Extended from el-table-column. Automatically adjust column width according to content. Keep all features of el-table-column.

Features

  • Automatically adjust column width according to content.
  • Extended from el-table-column, keep all features of el-table-column.

Using npm or yarn

$ npm install ex-table-column --save
$ yarn add ex-table-column

Demo

Clone repository and run:

$ yarn && yarn serve

Required

Quick Start

import Vue from 'vue'
import Element from 'element-ui'
import ExTableColumn from 'ex-table-column';

Vue.use(Element)
Vue.component(ExTableColumn.name, ExTableColumn);

Simple use

Replace <el-table-column /> to <ex-table-column>, add prop :autoFit='true':

<el-table>
  <ex-table-column
    :autoFit='true'
  />
</el-table>

And add style:

.el-table .cell {
  white-space: nowrap;
  width: fit-content;
}

Complicated slot

Add prop fitByClass to specify a class of the element, which is in slot component, and use to calculate the column width:

<el-table>
  <ex-table-column
    :autoFit='true'
    fitByClass="auto-fit-target"
    :fitGap="20"
  >
    <div class="column-wrapper" slot-scope="scope">
      <div class="column-content auto-fit-target">
        {{scope.row[scope.column.property]}}
      </div>
    </div>
  </ex-table-column>
</el-table>

Make sure that the element choosed by fitByClass, the width of the element is correct, maybe you should add white-space: nowrap; width: fit-content; for the element.

Extend prop

PropDescriptionTypeAccepted ValuesDefault
autoFitwhether column width to be automatically adjusted according to content, if set to be false, the behaves of <ex-table-column /> will be same as <el-table-column>.boolean-false
fitByClassSpecify the class of the element that determines the widthstring-cell
fitGapThe content right marginnumber-0
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago