Skip to content

DetailsList-DEMO


vue
<fv-DetailsList v-model="value" :head="head">
    <template v-slot:column_0="x">
        <p>{{x.item.name}}</p>
    </template>
    <template v-slot:column_1="x">
        <p class="sec">{{x.item.publisher}}</p>
    </template>
    <template v-slot:column_2="x">
        <p class="sec">{{x.item.publish_time}}</p>
    </template><template v-slot:column_3="x">
        <p class="sec">{{x.item.prop}}</p>
    </template>
    <template v-slot:column_4="x">
        <p class="sec">{{x.item.userInfo.name}}</p>
    </template>
  </fv-DetailsList>

DetailsList-Allow Drag


vue
<fv-DetailsList
  v-model="value"
  :head="head"
  :multiSelection="true"
  :compact="compact"
  :allowDrag="true"
>
      <template v-slot:column_0="x">
          <p>{{x.item.name}}</p>
      </template>
      <template v-slot:column_1="x">
          <p class="sec">{{x.item.publisher}}</p>
      </template>
      <template v-slot:column_2="x">
          <p class="sec">{{x.item.publish_time}}</p>
      </template><template v-slot:column_3="x">
          <p class="sec">{{x.item.prop}}</p>
      </template>
      <template v-slot:column_4="x">
          <p class="sec">{{x.item.userInfo.name}}</p>
      </template>
</fv-DetailsList>

DetailsList-Grouped


vue
<fv-DetailsList
  v-model="value"
  :head="head"
  :multiSelection="multiSelection"
  :compact="compact"
  :group="group"
  :showGroup="true"
>
    <template v-slot:column_0="x">
        <p>{{x.item.name}}</p>
    </template>
    <template v-slot:column_1="x">
        <p class="sec">{{x.item.publisher}}</p>
    </template>
    <template v-slot:column_2="x">
        <p class="sec">{{x.item.publish_time}}</p>
    </template><template v-slot:column_3="x">
        <p class="sec">{{x.item.prop}}</p>
    </template>
    <template v-slot:column_4="x">
        <p class="sec">{{x.item.userInfo.name}}</p>
    </template>
  </fv-DetailsList>

DetailsList-Dark Theme


vue
<fv-DetailsList
  v-model="value"
  :head="head"
  :multiSelection="multiSelection"
  :compact="compact"
>
    <template v-slot:column_0="x">
        <p>{{x.item.name}}</p>
    </template>
    <template v-slot:column_1="x">
        <p>{{x.item.publisher}}</p>
    </template>
    <template v-slot:column_2="x">
        <p>{{x.item.publish_time}}</p>
    </template><template v-slot:column_3="x">
        <p>{{x.item.prop}}</p>
    </template>
    <template v-slot:column_4="x">
        <p>{{x.item.userInfo.name}}</p>
    </template>
  </fv-DetailsList>

DetailsList Customize Row CSS


vue
<fv-DetailsList v-model="value" :head="head" :filter="filter" :multiSelection="multiSelection" :compact="compact" rowCss="fv-row-css">
    <template v-slot:column_0="x">
        <p>{{x.item.name}}</p>
    </template>
    <template v-slot:column_1="x">
        <p class="sec">{{x.item.publisher}}</p>
    </template>
    <template v-slot:column_2="x">
        <p class="sec">{{x.item.publish_time}}</p>
    </template><template v-slot:column_3="x">
        <p class="sec">{{x.item.prop}}</p>
    </template>
    <template v-slot:column_4="x">
        <p class="sec">{{x.item.userInfo.name}}</p>
    </template>
</fv-DetailsList>
scss
.fv-row-css
{
    &:nth-child(odd)
    {
        background: rgba(239, 239, 239, 1);
    }

    &:nth-child(even)
    {
        background: rgba(245, 245, 245, 1);
    }
}

Properties


PropertyTypeRequiredDefaultDescription
modelValuearrayNo[]See the DetailsList modelValue option.
headarrayNo[]See the DetailsList head option.
grouparrayNo[]See the DetailsList group option.
filterobjectNo() => { return { key: 'any', value: '' }; }See the DetailsList filter option.
showGroupbooleanNofalseSee the DetailsList showGroup option.
autoHeightbooleanNofalseSee the DetailsList autoHeight option.
foregroundstringNo''See the DetailsList foreground option.
headBackgroundstringNo''See the DetailsList headBackground option.
compactbooleanNofalseSee the DetailsList compact option.
multiSelectionbooleanNofalseSee the DetailsList multiSelection option.
allowDragbooleanNofalseSee the DetailsList allowDrag option.
rowCSSStringNoN/ASee the DetailsList rowCSS option.
rightMenuWidthnumberNo200See the DetailsList rightMenuWidth option.
showRightMenubooleanNotrueSee the DetailsList showRightMenu option.
rightMenuBackgroundstringNo''See the DetailsList rightMenuBackground option.
rightMenuFullExpandbooleanNofalseSee the DetailsList rightMenuFullExpand option.
themestringNo'global'Theme style. Supports global, light, dark, system, and custom.
rowCssstringNo''See the DetailsList rowCss option.
disabledbooleanNofalseSee the DetailsList disabled option.
langstringNo"global"See the DetailsList lang option.

Events


EventArgumentsDescription
change-value修改后的 valueSee the component change-value option.
choose-itemscurrentChooseSee the component choose-items option.
lazyload修改后的 valueSee the component lazyload option.
rightclick当前选中的 row-itemSee the component rightclick option.
drop-items返回对象包含transfervalueSee the component drop-items option.

Slots


  1. Head
vue
<template v-slot:head="x">
  <p class="default-title">{{ x.item.content }}</p>
</template>
  1. Column
vue
<template v-slot:column_0="x">
  <p>{{ x.item.name }}</p>
</template>
<template v-slot:column_1="x">
  <p class="sec">{{ x.item.publisher }}</p>
</template>
<template v-slot:column_2="x">
  <p class="sec">{{ x.item.publish_time }}</p> </template
><template v-slot:column_3="x">
  <p class="sec">{{ x.item.prop }}</p>
</template>
<template v-slot:column_4="x">
  <p class="sec">{{ x.item.userInfo.name }}</p>
</template>
  1. Row Expand
vue
<template v-slot:row_expand="x">
    <div style="position: absolute;"></div>
</template>
  1. Group
vue
<slot name="group" :item="gi" :index="i" :isMulti="multiSelection" :isChoose="isGroupChooseAll(gi)">
    <span v-show="multiSelection" class="icon-block icon" key="multi-col" @click="chooseGroup(gi)">
        <span class="icon" :class="{choose: isGroupChooseAll(gi)}">
            <i class="ms-Icon ms-Icon--FullCircleMask ll"></i>
            <i class="ms-Icon ms-Icon--CircleRing ll"></i>
            <i class="ms-Icon ms-Icon--Completed ll"></i>
        </span>
    </span>
    <span class="expand" :class="{choose: gi.expand}" @click="expandGroup(gi)">
        <i class="ms-Icon ms-Icon--ChevronRight"></i>
    </span>
    <span class="col">
        <p>{{gi.name}}</p>
    </span>
</slot>
vue
<template v-slot:group="x">
  <p>{{ x.item.name }}</p>
</template>
  1. Goup Content
vue
<slot name="group_content" :item="gi" :index="i">
    <span class="col">
        <p>{{gi.name}}</p>
    </span>
</slot>
vue
<template v-slot:group_content="x">
  <p>{{ x.item.name }}</p>
</template>
  1. Context Menu
vue
<template v-slot:menu>
  <div>
    <span>
      <i>[图标]</i>
      <p>[内容]</p>
    </span>
    ...
    <hr />
    <span>
      <i>[图标]</i>
      <p>[内容]</p>
    </span>
  </div>
</template>

Data


  1. value
javascript
value = [{any: '', ...}]

//e.g.//

value: [{id: "", name: "", publisher: "", userInfo: {}, publish_time: "", update_time: "", prop: ""}]
  1. head
javascript
head = [
  {
    content: "", //默认表头的列名
    minWidth: "", //最小的列宽, 默认为60
    width: "", //初始的列宽, 默认为80
    sortName: "", //按字段名来排序, 名字为value中的属性, DetailsList将根据当前的属性类型智能排序
    customSort: {}, //自定义排序方法, 在此定义函数满足预设两个参数(itemA, itemB)分别代表value中的两项并根据用户需要自定义函数方法, 此字段定义后, sortName仍需填写, 但值可任意
    visible: true //是否显示该列, 支持函数式声明
  }
];

**特别地** 0.2.17版本后支持采用函数式字段, 其中支持的字段包括`visible`

//e.g.//

head: [
  {
    content: "Name",
    minWidth: 60,
    width: 80,
    sortName: "name",
    visible: true
  },
  {
    content: "Publisher",
    minWidth: 60,
    width: 80,
    sortName: "publisher",
    visible: true
  },
  {
    content: "Publish Time",
    minWidth: 60,
    width: 190,
    sortName: "publish_time",
    visible: true
  },
  {
    content: "Prop",
    minWidth: 60,
    width: 92,
    sortName: "prop",
    visible: true
  },
  {
    content: "User Name",
    minWidth: 60,
    width: 80,
    visible: true
  }
];
  1. group
javascript
group = [
  {
    key: "", //分组的键值, 键来自value的属性
    value: "", //分组的键值对应的具体值, DetailsList会根据当前的key匹配value来进行分组
    name: "" //分组的其他数据, 默认模板将以name属性来渲染名称
  }
];

//e.g.//

group: [
  {
    key: "prop",
    value: "Windows",
    name: "A"
  },
  {
    key: "prop",
    value: "Edge",
    name: "B"
  },
  {
    key: "prop",
    value: "Office",
    name: "C"
  },
  {
    key: "prop",
    value: "Visual Studio",
    name: "D"
  }
];

Appendix


Custom Class


类名(Name)说明(statement)
fv-custom-head客制化表头, 主要递推关系: fv-custom-head -> icon-block, col -> col-content, expand -> default-title
fv-custom-row客制化行, 主要递推关系: fv-custom-row -> icon-block, col
fv-custom-group-row客制化组, 主要递推关系: fv-custom-group-row -> icon-blocks, expand, col
scss
.fv-custom-head {
  .icon-block {
    .icon {
    }
  }
  .col {
    .col-content {
      .default-title {
      }
    }

    .expand {
    }
  }
}

.fv-custom-row {
  .icon-block {
    .icon {
    }
  }
  .col {
  }
}

.fv-custom-group-row {
  &.choose {
  }

  .icon-block {
    .icon {
    }
  }
  .col {
  }

  .expand {
  }
}

MIT Licensed