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
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Performance</title>
        <meta name="viewport" content="width=570">
        <style>
            @import "../../dojo/resources/dojo.css";
            @import "../css/dgrid.css";
            @import "../css/skins/tundra.css";
            .heading {
                font-weight: bold;
                margin-left: 12px;
                padding-bottom: 0.25em;
            }
            .dgrid {
                margin: 10px;
            }
            /* this is not part of theme, but you can add odd-even coloring this way*/
            .dgrid-row-odd {
                background: #F2F5F9;
            }
 
            #grid {
                width: 68em;
                height: 50em;
                padding: 1px;
            }
        </style>
        <script src="../../dojo/dojo.js" 
            data-dojo-config="async: true"></script>
        <script>
            require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Keyboard", "dojo/_base/declare", "dgrid/test/data/testPerformanceStore", "dojo/domReady!"], 
                function(List, Grid, Selection, Keyboard, declare, testPerformanceStore){
                    var columns = [
                        { name: 'Column 0', field: 'id', width: '10%' },
                        { name: 'Column 1', field: 'integer', width: '10%' },
                        { name: 'Column 2', field: 'floatNum', width: '10%' },
                        { name: 'Column 3', field: 'date', width: '10%' },
                        { name: 'Column 4', field: 'date2', width: '10%' },
                        { name: 'Column 5', field: 'text', width: '10%' },
                        { name: 'Column 6', field: 'bool', width: '10%' },
                        { name: 'Column 7', field: 'bool2', width: '10%' },
                        { name: 'Column 8', field: 'price', width: '10%' },
                        { name: 'Column 9', field: 'today', width: '10%' }
                    ];
                    var start = new Date();
                    var grid = window.grid = new (declare([Grid, Selection, Keyboard]))({
                        collection: testPerformanceStore,
                        columns: columns
                    }, "grid");
                    console.log("startup time: " + (new Date() - start) + "ms");
                    
                    var processScroll = grid._processScroll;
                    grid._processScroll = function(evt){
                        var start = new Date();
                        processScroll.call(this, evt);
                        console.log("scroll time: " + (new Date() - start) + "ms");
                    };
                    
                    grid.on("dgrid-refresh-complete", function() {
                        console.log("Refresh completed");
                    });
                });
                
        </script>
    </head>
    <body class="tundra">
        <h2 class="heading">A performance test designed to go head to head with DataGrid's test_datagrid_performance.html</h2>
        <div>Test refresh while preserving scroll position:
            <button onclick="grid.refresh({keepScrollPosition:1})">refresh</button>
        </div>
        <div id="grid"></div>
    </body>
</html>