@@ -21,6 +21,8 @@ <h1>Cell sizeToContent options demo</h1>
2121 < p > new 9.x feature that size the items to fit their content height as to not have scroll bars
2222 (unless `sizeToContent:false` in C: case). Defaulting to different initial size (see code) to show grow/shrink behavior.</ p >
2323 < div >
24+ < a onClick ="clearGrid() " class ="btn btn-primary " href ="# "> clear</ a >
25+ < a onClick ="load() " class ="btn btn-primary " href ="# "> load</ a >
2426 column:
2527 < a onClick ="column(8) " class ="btn btn-primary " href ="# "> 8</ a >
2628 < a onClick ="column(12) " class ="btn btn-primary " href ="# "> 12</ a >
@@ -46,14 +48,22 @@ <h1>Cell sizeToContent options demo</h1>
4648 let grid = GridStack . init ( opts ) ;
4749 let text = 'some very large content that will normally not fit in the window.'
4850 text = text + text ;
51+ let count = 0 ;
4952 let items = [
5053 { x :0 , y :0 , w :2 , content : `<div>A no h: ${ text } </div>` } ,
5154 { x :2 , y :0 , w :1 , h :2 , content : '<div>B: shrink h=2</div>' } , // make taller than needed upfront
5255 { x :3 , y :0 , w :2 , sizeToContent : false , content : `<div>C: WILL SCROLL. ${ text } </div>` } , // prevent this from fitting testing
5356 { x :0 , y :1 , w :3 , content : `<div>D no h: ${ text } ${ text } </div>` } ,
5457 { 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 ++ ) ) ;
5559 grid . load ( items ) ;
5660
61+ function clearGrid ( ) {
62+ grid . removeAll ( ) ;
63+ }
64+ function load ( ) {
65+ grid . load ( items ) ;
66+ }
5767 function column ( n ) {
5868 grid . column ( n , 'none' ) ;
5969 }
@@ -85,6 +95,10 @@ <h1>Cell sizeToContent options demo</h1>
8595 let el = cont . parentElement . parentElement . parentElement ;
8696 grid . resizeToContent ( el ) ;
8797 }
98+
99+ // TEST
100+ // grid.update(grid.engine.nodes[0].el, {x:7});
101+ // load();
88102 </ script >
89103</ body >
90104</ html >
0 commit comments