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
bcbee7b4
Commit
bcbee7b4
authored
Nov 13, 2016
by
杨奕
Committed by
GitHub
Nov 13, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1016 from furybean/table-row-key
Table: render rows with row-key.
parents
19cadd14
69d56468
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
packages/table/src/table-body.js
packages/table/src/table-body.js
+10
-1
packages/table/src/table-store.js
packages/table/src/table-store.js
+1
-10
packages/table/src/util.js
packages/table/src/util.js
+9
-0
No files found.
packages/table/src/table-body.js
View file @
bcbee7b4
import
{
getValueByPath
,
getCell
,
getColumnByCell
}
from
'
./util
'
;
import
{
getValueByPath
,
getCell
,
getColumnByCell
,
getRowIdentity
}
from
'
./util
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -31,6 +31,7 @@ export default {
...
@@ -31,6 +31,7 @@ export default {
{
{
this
.
_l
(
this
.
data
,
(
row
,
$index
)
=>
this
.
_l
(
this
.
data
,
(
row
,
$index
)
=>
<
tr
<
tr
key
=
{
this
.
$parent
.
rowKey
?
this
.
getKeyOfRow
(
row
,
$index
)
:
$index
}
on
-
click
=
{
(
$event
)
=>
this
.
handleClick
(
$event
,
row
)
}
on
-
click
=
{
(
$event
)
=>
this
.
handleClick
(
$event
,
row
)
}
on
-
mouseenter
=
{
_
=>
this
.
handleMouseEnter
(
$index
)
}
on
-
mouseenter
=
{
_
=>
this
.
handleMouseEnter
(
$index
)
}
on
-
mouseleave
=
{
_
=>
this
.
handleMouseLeave
()
}
on
-
mouseleave
=
{
_
=>
this
.
handleMouseLeave
()
}
...
@@ -118,6 +119,14 @@ export default {
...
@@ -118,6 +119,14 @@ export default {
},
},
methods
:
{
methods
:
{
getKeyOfRow
(
row
,
index
)
{
const
rowKey
=
this
.
$parent
.
rowKey
;
if
(
rowKey
)
{
return
getRowIdentity
(
row
,
rowKey
);
}
return
index
;
},
isCellHidden
(
index
)
{
isCellHidden
(
index
)
{
if
(
this
.
fixed
===
true
||
this
.
fixed
===
'
left
'
)
{
if
(
this
.
fixed
===
true
||
this
.
fixed
===
'
left
'
)
{
return
index
>=
this
.
leftFixedCount
;
return
index
>=
this
.
leftFixedCount
;
...
...
packages/table/src/table-store.js
View file @
bcbee7b4
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
debounce
from
'
throttle-debounce/debounce
'
;
import
debounce
from
'
throttle-debounce/debounce
'
;
import
{
orderBy
,
getColumnById
}
from
'
./util
'
;
import
{
orderBy
,
getColumnById
,
getRowIdentity
}
from
'
./util
'
;
const
getRowIdentity
=
(
row
,
rowKey
)
=>
{
if
(
!
row
)
throw
new
Error
(
'
row is required when get row identity
'
);
if
(
typeof
rowKey
===
'
string
'
)
{
return
row
[
rowKey
];
}
else
if
(
typeof
rowKey
===
'
function
'
)
{
return
rowKey
.
call
(
null
,
row
);
}
};
const
sortData
=
(
data
,
states
)
=>
{
const
sortData
=
(
data
,
states
)
=>
{
const
sortingColumn
=
states
.
sortingColumn
;
const
sortingColumn
=
states
.
sortingColumn
;
...
...
packages/table/src/util.js
View file @
bcbee7b4
...
@@ -106,3 +106,12 @@ export const mousewheel = function(element, callback) {
...
@@ -106,3 +106,12 @@ export const mousewheel = function(element, callback) {
element
.
addEventListener
(
isFirefox
?
'
DOMMouseScroll
'
:
'
mousewheel
'
,
callback
);
element
.
addEventListener
(
isFirefox
?
'
DOMMouseScroll
'
:
'
mousewheel
'
,
callback
);
}
}
};
};
export
const
getRowIdentity
=
(
row
,
rowKey
)
=>
{
if
(
!
row
)
throw
new
Error
(
'
row is required when get row identity
'
);
if
(
typeof
rowKey
===
'
string
'
)
{
return
row
[
rowKey
];
}
else
if
(
typeof
rowKey
===
'
function
'
)
{
return
rowKey
.
call
(
null
,
row
);
}
};
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