Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Commit e023e60

Browse files
author
Ken Berkeley
committed
bak
1 parent 492bc41 commit e023e60

File tree

6 files changed

+38
-23
lines changed

6 files changed

+38
-23
lines changed

example-dist/client.96937642.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example-dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
1414
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
15-
<script type="text/javascript" src="client.73be7c4a.js"></script></body>
15+
<script type="text/javascript" src="client.96937642.js"></script></body>
1616
</html>

example/Advanced.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import comps from './comps/'
2121
import mockData from './mock'
2222
2323
export default {
24-
name: 'FriendsTable', // `name` is required as it is a recursive component!
24+
name: 'FriendsTable', // `name` is required as a recursive component!
2525
props: ['row'], // `props.row` from the parent FriendsTable (if exists)
2626
components: { Datatable, ...comps },
2727
data () {

example/mock/dataSource.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ for (let i = 1; i <= total; i++) {
1212
name: Random.name(),
1313
age: Random.integer(0, 100),
1414
email: Random.email(),
15-
friends: without( // exclude `myself`
16-
uniq(Array(getRandomUid()).fill().map(() => getRandomUid())) , i
15+
friends: without(
16+
uniq(Array(getRandomUid()).fill().map(() => getRandomUid())),
17+
i // exclude `myself`
1718
),
1819
country: Random.pick(
1920
['US', 'UK', 'China', 'Russia', 'Germany', 'France', 'Japan']

src/LimitSelect.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template>
22
<label>
3-
Show&nbsp;<select class="form-control input-sm inline-select" v-model="limit">
3+
Show
4+
<select class="form-control input-sm inline-select" v-model="limit">
45
<option v-for="i in options" :value="i">{{ i }}</option>
5-
</select>&nbsp;items per page
6+
</select>
7+
items per page
68
</label>
79
</template>
810
<script>

src/index.vue

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
<div>
33
<div v-if="$slots.default || HeaderSettings" class="m-b-10 clearfix">
44
<header-settings v-if="HeaderSettings" class="pull-right"
5-
:col-groups="columns" :support-backup="supportBackup" />
5+
:col-groups="columns" :support-backup="supportBackup">
6+
</header-settings>
67
<slot></slot>
78
</div>
8-
<!-- `.panel.panel-default` is for Rounded table, see http://stackoverflow.com/a/20903465/5172890 -->
9+
<!-- `.panel.panel-default` is for rounded table, see http://stackoverflow.com/a/20903465/5172890 -->
910
<div class="table-responsive panel panel-default">
1011
<table class="table table-striped table-hover" :class="{ 'table-bordered': tableBordered }">
1112
<thead>
1213
<transition-group name="fade" tag="tr">
1314
<th v-if="selection && data.length" width="1em" key="th-multi">
1415
<multi-select :selection="selection" :rows="data" />
1516
</th>
16-
<th v-for="(column, idx) in columns$"
17-
:key="column.title || column.field || idx"
17+
<th v-for="(column, idx) in columns$" :key="column.title || column.field || idx"
1818
:class="column.thClass" :style="column.thStyle">
19-
<!-- table head component (thComp) -->
20-
<component v-if="column.thComp" :is="comp[column.thComp]"
21-
:column="column" :field="column.field" :title="column.title"
22-
v-bind="$props"><!-- `v-bind` here is just like spread operator in JSX -->
19+
<!-- table head component (thComp). `v-bind` here is just like spread operator in JSX -->
20+
<component v-if="column.thComp" :is="comp[column.thComp]" v-bind="$props"
21+
:column="column" :field="column.field" :title="column.title">
2322
</component>
24-
<template v-else>{{ column.title }}</template>
23+
<template v-else>
24+
{{ column.title }}
25+
</template>
2526

2627
<i v-if="column.explain" class="fa fa-info-circle cursor-help" :title="column.explain"></i>
27-
<head-sort v-if="column.sort" :field="column.field" v-bind="$props" class="pull-right" />
28+
<head-sort v-if="column.sort" :field="column.field" :query="query" class="pull-right" />
2829
</th>
2930
</transition-group>
3031
</thead>
@@ -39,12 +40,14 @@
3940
<component v-if="column.tdComp" :is="comp[column.tdComp]" v-bind="$props"
4041
:row="item" :field="column.field" :value="item[column.field]" :nested="item.__nested__">
4142
</component>
42-
<template v-else>{{ item[column.field] }}</template>
43+
<template v-else>
44+
{{ item[column.field] }}
45+
</template>
4346
</td>
4447
</tr>
4548
<transition name="fade">
4649
<tr v-if="item.__nested__ && item.__nested__.visible">
47-
<td :colspan="columns$.length + (+!!selection)">
50+
<td :colspan="colspan">
4851
<!-- nested component -->
4952
<component :is="comp[item.__nested__.comp]"
5053
:row="item" :nested="item.__nested__" v-bind="$props">
@@ -54,7 +57,9 @@
5457
</transition>
5558
</template>
5659
<tr v-if="!data.length">
57-
<td :colspan="columns$.length + (+!!selection)" class="text-center text-muted">( No Data )</td>
60+
<td :colspan="colspan" class="text-center text-muted">
61+
( No Data )
62+
</td>
5863
</tr>
5964
<tr v-if="summary && data.length" class="-summary-row">
6065
<td v-if="selection" width="1em"></td>
@@ -65,7 +70,9 @@
6570
<component v-if="column.tdComp" :is="comp[column.tdComp]" v-bind="$props"
6671
:row="summary" :field="column.field" :value="summary[column.field]">
6772
</component>
68-
<template v-else>{{ summary[column.field] }}</template>
73+
<template v-else>
74+
{{ summary[column.field] }}
75+
</template>
6976
</td>
7077
<td v-else>
7178
<!-- show summary label if the first column field has no data -->
@@ -79,10 +86,10 @@
7986
<div v-if="Pagination" class="row">
8087
<div class="col-sm-6 nowrap">
8188
<strong>Total {{ total }} ,</strong>
82-
<limit-select v-bind="$props" />
89+
<limit-select :query="query" />
8390
</div>
8491
<div class="col-sm-6">
85-
<pagination class="pull-right" v-bind="$props" />
92+
<pagination class="pull-right" :total="total" :query="query" />
8693
</div>
8794
</div>
8895
</div>
@@ -111,7 +118,7 @@ export default {
111118
xprops: Object, // extra custom props passing to dynamic components
112119
supportBackup: Boolean, // support header settings backup
113120
supportNested: Boolean, // support nested components
114-
tableBordered: Boolean // add .table-bordered to <table>
121+
tableBordered: Boolean // add `.table-bordered` to <table>
115122
},
116123
created () { // init query
117124
const { query } = this
@@ -138,6 +145,9 @@ export default {
138145
// the sort shown below is not stable
139146
// return columns$.map(col => ((col.weight = col.weight || 0), col)).sort((a, b) => b.weight - a.weight)
140147
},
148+
colspan () {
149+
return this.columns$.length + (+!!this.selection)
150+
},
141151
data$ () {
142152
const { data } = this
143153
if (this.supportNested) {

0 commit comments

Comments
 (0)