summaryrefslogtreecommitdiff
path: root/swat/apps/qooxdoo-examples/test/ListView_7.html
blob: 44babe954c1fe3b379d1ec9a8ebbb203318c820d (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>qooxdoo &raquo; Demo</title>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout.css"/>
  <!--[if IE]>
  <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
  <![endif]-->
  <script type="text/javascript" src="../../script/qx.js"></script>
</head>
<body>
  <script type="text/javascript" src="../../script/layout.js"></script>

  <div id="demoDescription">
    <p>Testing qx.ui.listview.ListView with text cells.</p>
    <p>Added some buttons to fill/clear the list dynamically.</p>
  </div>

  <script type="text/javascript">
    qx.core.Init.getInstance().defineMain(function()
    {
      var ld = [];
      var lt = [ "Image", "Text", "PDF", "Illustration", "Document" ];

      var lc =
      {
        name : { label : "Name", width : 100, type : "text", sortable : true, sortProp : "text" },
        size: { label : "Size", width : 50, type : "text", sortable : true, sortProp : "text", sortMethod : qx.util.Compare.byIntegerString },
        type : { label : "Type", width : 80, type : "text", sortable : true, sortProp : "text" },
        modified : { label : "Last Modified", width : 150, type : "text" },
        rights : { label : "Rights", width: 80, type : "text" }
      };

      var lv = new qx.ui.listview.ListView(ld, lc);

      lv.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
      lv.setBackgroundColor("white");
      lv.setWidth(500);
      lv.setHeight(350);
      lv.setLocation(20, 48);

      qx.ui.core.ClientDocument.getInstance().add(lv);

      function add(nu)
      {
        nu = nu||10;

        for (var i=0, t; i<nu; i++)
        {
          t=Math.round(Math.random()*4);
          ld.push({ name : { text : "File " + ld.length }, size : { text : Math.round(Math.random()*100) + "kb" }, type : { text : lt[t] }, modified : { text : "Nov " + Math.round(Math.random() * 30 + 1) + " 2005" }, rights: { text : "-rw-r--r--" }});
        };

        lv.updateSort();
        lv.update();
      };

      function remove(nu)
      {
        nu = Math.min(ld.length, nu || 10);

        ld.splice(ld.length-nu, nu);

        lv.updateSort();
        lv.update();
      };

      function clear()
      {
        ld.removeAll();
        lv.update();
      };

      var btnAdd10 = new qx.ui.form.Button("Add 10", "icon/16/insert-table-row.png");
      var btnAdd50 = new qx.ui.form.Button("Add 50", "icon/16/insert-table-row.png");
      var btnAdd100 = new qx.ui.form.Button("Add 100", "icon/16/insert-table-row.png");
      var btnAdd1000 = new qx.ui.form.Button("Add 1000", "icon/16/insert-table-row.png");

      var btnRemove10 = new qx.ui.form.Button("Remove 10", "icon/16/delete-table-row.png");
      var btnRemove50 = new qx.ui.form.Button("Remove 50", "icon/16/delete-table-row.png");
      var btnRemove100 = new qx.ui.form.Button("Remove 100", "icon/16/delete-table-row.png");
      var btnRemove1000 = new qx.ui.form.Button("Remove 1000", "icon/16/delete-table-row.png");

      var btnClear = new qx.ui.form.Button("Clear", "icon/16/delete-table.png");

      btnAdd10.setLocation(550, 48);
      btnAdd50.setLocation(550, 78);
      btnAdd100.setLocation(550, 108);
      btnAdd1000.setLocation(550, 138);

      btnRemove10.setLocation(550, 188);
      btnRemove50.setLocation(550, 218);
      btnRemove100.setLocation(550, 248);
      btnRemove1000.setLocation(550, 278);

      btnClear.setLocation(550, 328);

      btnAdd10.addEventListener("execute", function(e) { add(10); });
      btnAdd50.addEventListener("execute", function(e) { add(50); });
      btnAdd100.addEventListener("execute", function(e) { add(100); });
      btnAdd1000.addEventListener("execute", function(e) { add(1000); });

      btnRemove10.addEventListener("execute", function(e) { remove(10); });
      btnRemove50.addEventListener("execute", function(e) { remove(50); });
      btnRemove100.addEventListener("execute", function(e) { remove(100); });
      btnRemove1000.addEventListener("execute", function(e) { remove(1000); });

      btnClear.addEventListener("execute", function(e) { clear(); });

      qx.ui.core.ClientDocument.getInstance().add(btnAdd10, btnAdd50, btnAdd100, btnAdd1000, btnRemove10, btnRemove50, btnRemove100, btnRemove1000, btnClear);
    });
  </script>
</body>
</html>