liuyg
2021-07-02 25ce610f6ecca7325e7a743dc032c4a76559c63d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Tile Layout in OnDemandList</title>
        <style>
            @import "../../dojo/resources/dojo.css";
            @import "../css/dgrid.css";
            @import "../css/skins/claro.css";
            .dgrid {
                margin: 10px;
                width: 430px;
                height: 400px;
                float: left;
            }
 
            #list .dgrid-row {
                display: inline-block;
                width: 100px;
                height: 100px;
            }
 
            #imglist .dgrid-row {
                width: 64px;
                height: 64px;
            }
 
            .clear {
                clear: both;
            }
        </style>
        <script src="../../dojo/dojo.js"
            data-dojo-config="async: true"></script>
        <script>
            var logRendered; // Function defined in require factory
            require(["dgrid/OnDemandList", "dojo/dom-construct", "dojo/query", "dstore/Memory", "dojo/domReady!"],
            function(OnDemandList, domConstruct, query, Memory){
                // Create dummy array to make list show a number of entries.
                var data = [], i, store;
                for(i = 0; i < 500; i++){ data[i] = { id: i }; }
                store = new Memory({ data: data });
 
                logRendered = function(){
                    console.log("list: " + query("#list .dgrid-row").length);
                    console.log("imglist: " + query("#imglist .dgrid-row").length);
                };
                document.getElementById("logRendered").onclick = logRendered;
 
                window.list = new OnDemandList({
                    collection: store,
                    farOffRemoval: 500,
                    renderRow: function(object){
                        return domConstruct.create('span', { innerHTML: object.id });
                    }
                }, "list");
 
                window.imglist = new OnDemandList({
                    collection: store,
                    farOffRemoval: 500,
                    renderRow: function(object){
                        return domConstruct.create('img', { src: '../demos/multiview/resources/dojo-64.png' });
                    }
                }, "imglist");
            });
 
        </script>
    </head>
    <body class="claro">
        <h2>OnDemandLists with a tiled layout, for testing virtual paging</h2>
        <div id="list"></div>
        <div id="imglist"></div>
        <div class="clear">
            <button id="logRendered">Log number of rendered items</button>
        </div>
    </body>
</html>