Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
bad78d02
Commit
bad78d02
authored
Dec 22, 2016
by
baiyaaaaa
Committed by
GitHub
Dec 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1895 from Kingwl/dev
Table: add header-align, Fixed #1424
parents
cecf9eb8
aca352e7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
1 deletion
+47
-1
examples/docs/zh-CN/table.md
examples/docs/zh-CN/table.md
+1
-0
packages/table/src/table-column.js
packages/table/src/table-column.js
+8
-0
packages/table/src/table-header.js
packages/table/src/table-header.js
+1
-1
test/unit/specs/table.spec.js
test/unit/specs/table.spec.js
+37
-0
No files found.
examples/docs/zh-CN/table.md
View file @
bad78d02
...
@@ -1421,6 +1421,7 @@
...
@@ -1421,6 +1421,7 @@
| context | 设置上下文环境,例如设置当前上下文就是
`_self`
,父级就是
`$parent`
,根组件
`$root`
| Object | - | Table 所处上下文 |
| context | 设置上下文环境,例如设置当前上下文就是
`_self`
,父级就是
`$parent`
,根组件
`$root`
| Object | - | Table 所处上下文 |
| inline-template | 指定该属性后可以自定义 column 模板,参考多选的时间列,通过 row 获取行信息。总共可以获取到
`{ row(当前行), column(当前列), $index(行数), store(table store) }`
以及 Table 所处的上下文环境。 | — | — |
| inline-template | 指定该属性后可以自定义 column 模板,参考多选的时间列,通过 row 获取行信息。总共可以获取到
`{ row(当前行), column(当前列), $index(行数), store(table store) }`
以及 Table 所处的上下文环境。 | — | — |
| align | 对齐方式 | String | left, center, right | left |
| align | 对齐方式 | String | left, center, right | left |
| header_align | 表头对齐方式,若不设置该项,则使用表格的对齐方式 | String | left, center, right | — |
| class-name | 列的 className | string | — | — |
| class-name | 列的 className | string | — | — |
| selectable | 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 | Function(row, index) | — | — |
| selectable | 仅对 type=selection 的列有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选 | Function(row, index) | — | — |
| reserve-selection | 仅对 type=selection 的列有效,类型为 Boolean,为 true 则代表会保留之前数据的选项,需要配合 Table 的 clearSelection 方法使用。 | Boolean | — | false |
| reserve-selection | 仅对 type=selection 的列有效,类型为 Boolean,为 true 则代表会保留之前数据的选项,需要配合 Table 的 clearSelection 方法使用。 | Boolean | — | false |
...
...
packages/table/src/table-column.js
View file @
bad78d02
...
@@ -114,6 +114,7 @@ export default {
...
@@ -114,6 +114,7 @@ export default {
context
:
{},
context
:
{},
columnKey
:
String
,
columnKey
:
String
,
align
:
String
,
align
:
String
,
headerAlign
:
String
,
showTooltipWhenOverflow
:
Boolean
,
showTooltipWhenOverflow
:
Boolean
,
showOverflowTooltip
:
Boolean
,
showOverflowTooltip
:
Boolean
,
fixed
:
[
Boolean
,
String
],
fixed
:
[
Boolean
,
String
],
...
@@ -205,6 +206,7 @@ export default {
...
@@ -205,6 +206,7 @@ export default {
isColumnGroup
,
isColumnGroup
,
context
:
this
.
context
,
context
:
this
.
context
,
align
:
this
.
align
?
'
is-
'
+
this
.
align
:
null
,
align
:
this
.
align
?
'
is-
'
+
this
.
align
:
null
,
headerAlign
:
this
.
headerAlign
?
'
is-
'
+
this
.
headerAlign
:
(
this
.
align
?
'
is-
'
+
this
.
align
:
null
),
sortable
:
this
.
sortable
,
sortable
:
this
.
sortable
,
sortMethod
:
this
.
sortMethod
,
sortMethod
:
this
.
sortMethod
,
resizable
:
this
.
resizable
,
resizable
:
this
.
resizable
,
...
@@ -305,6 +307,12 @@ export default {
...
@@ -305,6 +307,12 @@ export default {
}
}
},
},
headerAlign
(
newVal
)
{
if
(
this
.
columnConfig
)
{
this
.
columnConfig
.
headerAlign
=
newVal
?
'
is-
'
+
newVal
:
this
.
align
;
}
},
width
(
newVal
)
{
width
(
newVal
)
{
if
(
this
.
columnConfig
)
{
if
(
this
.
columnConfig
)
{
this
.
columnConfig
.
width
=
newVal
;
this
.
columnConfig
.
width
=
newVal
;
...
...
packages/table/src/table-header.js
View file @
bad78d02
...
@@ -103,7 +103,7 @@ export default {
...
@@ -103,7 +103,7 @@ export default {
on
-
mouseout
=
{
this
.
handleMouseOut
}
on
-
mouseout
=
{
this
.
handleMouseOut
}
on
-
mousedown
=
{
(
$event
)
=>
this
.
handleMouseDown
(
$event
,
column
)
}
on
-
mousedown
=
{
(
$event
)
=>
this
.
handleMouseDown
(
$event
,
column
)
}
on
-
click
=
{
(
$event
)
=>
this
.
handleClick
(
$event
,
column
)
}
on
-
click
=
{
(
$event
)
=>
this
.
handleClick
(
$event
,
column
)
}
class
=
{
[
column
.
id
,
column
.
order
,
column
.
a
lign
,
column
.
className
||
''
,
rowIndex
===
0
&&
this
.
isCellHidden
(
cellIndex
)
?
'
is-hidden
'
:
''
,
!
column
.
children
?
'
is-leaf
'
:
''
]
}
>
class
=
{
[
column
.
id
,
column
.
order
,
column
.
headerA
lign
,
column
.
className
||
''
,
rowIndex
===
0
&&
this
.
isCellHidden
(
cellIndex
)
?
'
is-hidden
'
:
''
,
!
column
.
children
?
'
is-leaf
'
:
''
]
}
>
<
div
class
=
{
[
'
cell
'
,
column
.
filteredValue
&&
column
.
filteredValue
.
length
>
0
?
'
highlight
'
:
''
]
}
>
<
div
class
=
{
[
'
cell
'
,
column
.
filteredValue
&&
column
.
filteredValue
.
length
>
0
?
'
highlight
'
:
''
]
}
>
{
{
column
.
renderHeader
column
.
renderHeader
...
...
test/unit/specs/table.spec.js
View file @
bad78d02
...
@@ -1215,6 +1215,43 @@ describe('Table', () => {
...
@@ -1215,6 +1215,43 @@ describe('Table', () => {
},
DELAY
);
},
DELAY
);
});
});
it
(
'
header-align
'
,
(
done
)
=>
{
const
vm
=
createVue
({
template
:
`
<el-table :data="testData">
<el-table-column prop="name" :align="align" :header-align="headerAlign"/>
</el-table>
`
,
data
()
{
return
{
align
:
'
left
'
,
headerAlign
:
null
};
},
created
()
{
this
.
testData
=
getTestData
();
}
},
true
);
setTimeout
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header th.is-left
'
).
length
>
0
).
to
.
be
.
true
;
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header td.is-center
'
).
length
===
0
).
to
.
be
.
true
;
vm
.
align
=
'
right
'
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header th.is-right
'
).
length
>
0
).
to
.
be
.
true
;
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header td.is-center
'
).
length
===
0
).
to
.
be
.
true
;
vm
.
headerAlign
=
'
center
'
;
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header th.is-right
'
).
length
===
0
).
to
.
be
.
true
;
expect
(
vm
.
$el
.
querySelectorAll
(
'
.el-table__header td.is-center
'
).
length
>
0
).
to
.
be
.
true
;
});
});
done
();
},
DELAY
);
});
it
(
'
width
'
,
(
done
)
=>
{
it
(
'
width
'
,
(
done
)
=>
{
const
vm
=
createVue
({
const
vm
=
createVue
({
template
:
`
template
:
`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment