@@ -21,6 +21,8 @@ <h1>Cell sizeToContent options demo</h1>
21
21
< p > new 9.x feature that size the items to fit their content height as to not have scroll bars
22
22
(unless `sizeToContent:false` in C: case). Defaulting to different initial size (see code) to show grow/shrink behavior.</ p >
23
23
< div >
24
+ < a onClick ="clearGrid() " class ="btn btn-primary " href ="# "> clear</ a >
25
+ < a onClick ="load() " class ="btn btn-primary " href ="# "> load</ a >
24
26
column:
25
27
< a onClick ="column(8) " class ="btn btn-primary " href ="# "> 8</ a >
26
28
< a onClick ="column(12) " class ="btn btn-primary " href ="# "> 12</ a >
@@ -46,14 +48,22 @@ <h1>Cell sizeToContent options demo</h1>
46
48
let grid = GridStack . init ( opts ) ;
47
49
let text = 'some very large content that will normally not fit in the window.'
48
50
text = text + text ;
51
+ let count = 0 ;
49
52
let items = [
50
53
{ x :0 , y :0 , w :2 , content : `<div>A no h: ${ text } </div>` } ,
51
54
{ x :2 , y :0 , w :1 , h :2 , content : '<div>B: shrink h=2</div>' } , // make taller than needed upfront
52
55
{ x :3 , y :0 , w :2 , sizeToContent : false , content : `<div>C: WILL SCROLL. ${ text } </div>` } , // prevent this from fitting testing
53
56
{ x :0 , y :1 , w :3 , content : `<div>D no h: ${ text } ${ text } </div>` } ,
54
57
{ x :3 , y :1 , w :2 , sizeToContent :3 , content : `<div>E sizeToContent=3 <button onClick="more()">more</button><button onClick="less()">less</button><div id="dynContent">${ text } ${ text } ${ text } </div></div>` } ] ;
58
+ items . forEach ( n => n . id = String ( count ++ ) ) ;
55
59
grid . load ( items ) ;
56
60
61
+ function clearGrid ( ) {
62
+ grid . removeAll ( ) ;
63
+ }
64
+ function load ( ) {
65
+ grid . load ( items ) ;
66
+ }
57
67
function column ( n ) {
58
68
grid . column ( n , 'none' ) ;
59
69
}
@@ -85,6 +95,10 @@ <h1>Cell sizeToContent options demo</h1>
85
95
let el = cont . parentElement . parentElement . parentElement ;
86
96
grid . resizeToContent ( el ) ;
87
97
}
98
+
99
+ // TEST
100
+ // grid.update(grid.engine.nodes[0].el, {x:7});
101
+ // load();
88
102
</ script >
89
103
</ body >
90
104
</ html >
0 commit comments