File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1
1
import HyperList from 'hyperlist' ;
2
-
3
2
export default class BodyRenderer {
4
3
constructor ( instance ) {
5
4
this . instance = instance ;
@@ -15,9 +14,10 @@ export default class BodyRenderer {
15
14
renderRows ( rows ) {
16
15
this . visibleRows = rows ;
17
16
this . visibleRowIndices = rows . map ( row => row . meta . rowIndex ) ;
18
-
17
+ this . instance . noData = false ;
19
18
if ( rows . length === 0 ) {
20
19
this . bodyScrollable . innerHTML = this . getNoDataHTML ( ) ;
20
+ this . instance . noData = true ;
21
21
this . footer . innerHTML = '' ;
22
22
return ;
23
23
}
@@ -140,7 +140,18 @@ export default class BodyRenderer {
140
140
}
141
141
142
142
getNoDataHTML ( ) {
143
- return `<div class="dt-scrollable__no-data">${ this . options . noDataMessage } </div>` ;
143
+ const width = this . instance . header . scrollWidth ;
144
+ const height = this . bodyScrollable . clientHeight ;
145
+ return `
146
+ <div
147
+ class="dt-scrollable__no-data"
148
+ style="width: ${ width - 2 } px; height: ${ height } px"
149
+ >
150
+ <div class="dt-scrollable__no-data no-data-message">
151
+ ${ this . options . noDataMessage }
152
+ </div>
153
+ </div>
154
+ ` ;
144
155
}
145
156
146
157
getToastMessageHTML ( message ) {
Original file line number Diff line number Diff line change 16
16
--dt-selection-highlight-color : var (--dt-light-yellow );
17
17
--dt-toast-message-border : none;
18
18
--dt-header-cell-bg : var (--dt-cell-bg );
19
+ --dt-no-data-message-width : 90px ;
19
20
}
20
21
21
22
.datatable {
54
55
padding : var (--dt-spacer-3 );
55
56
border-left : 1px solid var (--dt-border-color );
56
57
border-right : 1px solid var (--dt-border-color );
58
+ .no-data-message {
59
+ position : absolute;
60
+ top : 100px ;
61
+ left : 50px ;
62
+ border : none;
63
+ width : var (--dt-no-data-message-width );
64
+ }
57
65
}
66
+
58
67
}
59
68
60
69
.dt-row {
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ export default class Style {
77
77
// Find corresponding footer cell
78
78
const footerCell = this . footer . querySelector ( `.dt-cell[data-col-index="${ colIndex } "]` ) ;
79
79
80
- if ( ~ ~ ( bodyCell . offsetLeft - scrollLeft ) > colLeft ) {
80
+ if ( bodyCell && ~ ~ ( bodyCell . offsetLeft - scrollLeft ) > colLeft ) {
81
81
headerCell . style . transform = `translateX(${ - scrollLeft - 1 } px)` ;
82
82
if ( footerCell ) {
83
83
footerCell . style . transform = `translateX(${ scrollLeft ? - scrollLeft - 1 : 0 } px)` ;
@@ -89,6 +89,12 @@ export default class Style {
89
89
} ) ;
90
90
91
91
this . _settingHeaderPosition = false ;
92
+ if ( this . instance . noData ) {
93
+ $ . style ( $ ( '.no-data-message' ) , {
94
+ left : `${ this . instance . wrapper . clientWidth / 2 - ( - scrollLeft ) } px`
95
+ } ) ;
96
+ }
97
+ this . _settingHeaderPosition = false ;
92
98
} ) ;
93
99
} ) ;
94
100
}
You can’t perform that action at this time.
0 commit comments