@@ -11,7 +11,7 @@ object TableDemo {
11
11
def datum (data : List [DataRow ])(i : Int ) = data(i % data.length)
12
12
def rowheight (data : List [DataRow ])(i : Int ) = datum(data)(i).size
13
13
14
- final case class Props (useDynamicRowHeight : Boolean , sortBy : String )
14
+ final case class Props (useDynamicRowHeight : Boolean , sortBy : String , s : Size )
15
15
final case class State (sortDirection : SortDirection , data : List [DataRow ])
16
16
17
17
def headerRenderer (sortBy : String )(p : HeaderRendererParameter ): VdomNode =
@@ -27,7 +27,6 @@ object TableDemo {
27
27
.initialState(State (SortDirection .ASC , Data .generateRandomList))
28
28
.renderPS{($, props, state) =>
29
29
def sort (index : String , sortDirection : SortDirection ): Callback = {
30
- println(state.data.head.index)
31
30
val sorted = state.data.sortBy(_.index)
32
31
$.setState(state.copy(data = if (sortDirection == SortDirection .ASC ) sorted else sorted.reverse, sortDirection = sortDirection))
33
32
}
@@ -45,7 +44,7 @@ object TableDemo {
45
44
height = 270 ,
46
45
rowCount = 1000 ,
47
46
rowHeight = if (props.useDynamicRowHeight) rowheight(state.data) _ else 40 ,
48
- width = 500 ,
47
+ width = props.s.width.toInt ,
49
48
rowGetter = datum(state.data),
50
49
headerClassName = " headerColumn" ,
51
50
sort = sort _,
@@ -57,9 +56,13 @@ object TableDemo {
57
56
58
57
def apply (p : Props ) = component(p)
59
58
}
59
+
60
60
object Demo {
61
61
def main (args : Array [String ]): Unit = {
62
- TableDemo (TableDemo .Props (true , " index" )).renderIntoDOM(document.getElementById(" root" ))
62
+ val tableF = (s : Size ) =>
63
+ TableDemo (TableDemo .Props (true , " index" , s)).vdomElement
64
+
65
+ AutoSizer (AutoSizer .props(tableF, disableHeight = true )).renderIntoDOM(document.getElementById(" root" ))
63
66
println(" dem" )
64
67
}
65
68
}
0 commit comments