Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
9bcc9b06
Commit
9bcc9b06
authored
Mar 15, 2019
by
ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calculate the column width
parent
e6cba97b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
packages/grafana-ui/src/components/Table/Table.tsx
+12
-4
No files found.
packages/grafana-ui/src/components/Table/Table.tsx
View file @
9bcc9b06
...
@@ -8,6 +8,7 @@ import {
...
@@ -8,6 +8,7 @@ import {
CellMeasurerCache
,
CellMeasurerCache
,
CellMeasurer
,
CellMeasurer
,
GridCellProps
,
GridCellProps
,
Index
,
}
from
'react-virtualized'
;
}
from
'react-virtualized'
;
import
{
Themeable
}
from
'../../types/theme'
;
import
{
Themeable
}
from
'../../types/theme'
;
...
@@ -26,6 +27,7 @@ import { stringToJsRegex } from '../../utils/index';
...
@@ -26,6 +27,7 @@ import { stringToJsRegex } from '../../utils/index';
export
interface
Props
extends
Themeable
{
export
interface
Props
extends
Themeable
{
data
:
TableData
;
data
:
TableData
;
minColumnWidth
:
number
;
showHeader
:
boolean
;
showHeader
:
boolean
;
fixedHeader
:
boolean
;
fixedHeader
:
boolean
;
fixedColumns
:
number
;
fixedColumns
:
number
;
...
@@ -46,6 +48,7 @@ interface State {
...
@@ -46,6 +48,7 @@ interface State {
interface
ColumnRenderInfo
{
interface
ColumnRenderInfo
{
header
:
string
;
header
:
string
;
width
:
number
;
builder
:
TableCellBuilder
;
builder
:
TableCellBuilder
;
}
}
...
@@ -64,6 +67,7 @@ export class Table extends Component<Props, State> {
...
@@ -64,6 +67,7 @@ export class Table extends Component<Props, State> {
fixedHeader
:
true
,
fixedHeader
:
true
,
fixedColumns
:
0
,
fixedColumns
:
0
,
rotate
:
false
,
rotate
:
false
,
minColumnWidth
:
150
,
};
};
constructor
(
props
:
Props
)
{
constructor
(
props
:
Props
)
{
...
@@ -76,9 +80,7 @@ export class Table extends Component<Props, State> {
...
@@ -76,9 +80,7 @@ export class Table extends Component<Props, State> {
this
.
renderer
=
this
.
initColumns
(
props
);
this
.
renderer
=
this
.
initColumns
(
props
);
this
.
measurer
=
new
CellMeasurerCache
({
this
.
measurer
=
new
CellMeasurerCache
({
defaultHeight
:
30
,
defaultHeight
:
30
,
defaultWidth
:
150
,
fixedWidth
:
true
,
fixedWidth
:
true
,
fixedHeight
:
true
,
});
});
}
}
...
@@ -112,7 +114,8 @@ export class Table extends Component<Props, State> {
...
@@ -112,7 +114,8 @@ export class Table extends Component<Props, State> {
/** Given the configuration, setup how each column gets rendered */
/** Given the configuration, setup how each column gets rendered */
initColumns
(
props
:
Props
):
ColumnRenderInfo
[]
{
initColumns
(
props
:
Props
):
ColumnRenderInfo
[]
{
const
{
styles
,
data
}
=
props
;
const
{
styles
,
data
,
width
,
minColumnWidth
}
=
props
;
const
columnWidth
=
Math
.
max
(
width
/
data
.
columns
.
length
,
minColumnWidth
);
return
data
.
columns
.
map
((
col
,
index
)
=>
{
return
data
.
columns
.
map
((
col
,
index
)
=>
{
let
title
=
col
.
text
;
let
title
=
col
.
text
;
...
@@ -133,6 +136,7 @@ export class Table extends Component<Props, State> {
...
@@ -133,6 +136,7 @@ export class Table extends Component<Props, State> {
return
{
return
{
header
:
title
,
header
:
title
,
width
:
columnWidth
,
builder
:
getCellBuilder
(
col
,
style
,
this
.
props
),
builder
:
getCellBuilder
(
col
,
style
,
this
.
props
),
};
};
});
});
...
@@ -230,6 +234,10 @@ export class Table extends Component<Props, State> {
...
@@ -230,6 +234,10 @@ export class Table extends Component<Props, State> {
);
);
};
};
getColumnWidth
=
(
col
:
Index
):
number
=>
{
return
this
.
renderer
[
col
.
index
].
width
;
};
render
()
{
render
()
{
const
{
showHeader
,
fixedHeader
,
fixedColumns
,
rotate
,
width
,
height
}
=
this
.
props
;
const
{
showHeader
,
fixedHeader
,
fixedColumns
,
rotate
,
width
,
height
}
=
this
.
props
;
const
{
data
}
=
this
.
state
;
const
{
data
}
=
this
.
state
;
...
@@ -271,7 +279,7 @@ export class Table extends Component<Props, State> {
...
@@ -271,7 +279,7 @@ export class Table extends Component<Props, State> {
rowCount=
{
rowCount
}
rowCount=
{
rowCount
}
overscanColumnCount=
{
8
}
overscanColumnCount=
{
8
}
overscanRowCount=
{
8
}
overscanRowCount=
{
8
}
columnWidth=
{
this
.
measurer
.
c
olumnWidth
}
columnWidth=
{
this
.
getC
olumnWidth
}
deferredMeasurementCache=
{
this
.
measurer
}
deferredMeasurementCache=
{
this
.
measurer
}
cellRenderer=
{
this
.
cellRenderer
}
cellRenderer=
{
this
.
cellRenderer
}
rowHeight=
{
this
.
measurer
.
rowHeight
}
rowHeight=
{
this
.
measurer
.
rowHeight
}
...
...
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