1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4
<title>Datatable Tests</title>
5
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssreset/reset-min.css">
6
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssbase/base-min.css">
7
<script type="text/javascript" src="../../../build/yui/yui-debug.js"></script>
11
font-family: sans-serif;
19
border:1px solid #C9C675;
38
<body class="yui3-skin-sam">
39
<h1>Datatable Tests</h1>
41
<p>To test the performance of various datatables, look at the following sections in the code:
44
//large or small dataset.
47
//---------------------------------------------
48
// Special instructions
49
//---------------------------------------------
53
//ignore following tests (good to do if you are doing a large dataset)
54
testBaseDatatable: true,
55
testXYDatatable: true,
57
testYDatatable_FixedCol: true,
58
testYDatatable_AutoCol: true,
59
testXYDatatable_BigHeaders: false
64
Toggle <code>data</code> from <code>large</code> to <code>small</code> to get a different sized dataset. The <code>ignore</code> object determines which table to load. If testing performance, it is recommended that you only enable 1 table at a time.</p>
66
<p><input type="button" value="Run Tests" id="btnRun" disabled=true></p>
72
<h3>Base Datatable</h3>
75
<h3>Scrolling XY Datatable (Set columnwidths)</h3>
76
<P>A general XY scrolling datatable. Column widths are provided for all columns, table width and height is provided.</p>
77
<div id="scrolling-xy"></div>
79
<h3>Scrolling X Datatable (Auto Columns)</h3>
80
<p>A X-scrolling datatable. Column A and B have specified widths. The rest of the columns do not have any widths specified. Only a height of 200px is specified.</p>
81
<div id="scrolling-x"></div>
83
<h3>Scrolling Y Datatable</h3>
84
<p>A Y-scrolling datatable. Column widths are provided for all columns, table height is provided. Since all cols have specified width, you may see this table overflowing past its container div (the blue div in the background). </p>
85
<div id="scrolling-y"></div>
87
<h3>Scrolling Datatable with no ColumnWidth</h3>
88
<p>A Y-scrolling datatable, where only the first 2 columns have a specified width. Only the table height is provided.</p>
89
<div id="scrolling-colwidth"></div>
91
<h3>Scrolling Datatable with Big Headers</h3>
92
<p>A XY-scrolling datatable, where only the first 2 columns have a specified width. Table height and width is provided. The table headers are of larger width than the table contents</p>
93
<div id="scrolling-bigcols"></div>
96
<script type="text/javascript">
102
filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min',
104
useBrowserConsole: true
105
}).use("console", "test", "dump", "datatable","node","json-parse", function(Y) {
109
var ASSERT = Y.Assert,
110
ARRAYASSERT = Y.ArrayAssert,
111
BTNRUN = Y.one("#btnRun"),
112
TestRunner = Y.Test.Runner;
113
BTNRUN.set("disabled", false);
114
TestRunner.subscribe(TestRunner.TEST_CASE_COMPLETE_EVENT, testCompleted);
115
Y.on("click", function(e){
117
BTNRUN.set("value", 'Running...');
118
BTNRUN.set("disabled", true);
122
function testCompleted() {
123
BTNRUN.set("value", 'Test Completed');
124
Y.log('Test Completed');
126
var myConsole = new Y.Console().render();
135
for (var i=0; i<500; i++) {
136
large[i] = {a: i+1, b:i+2, c:i+3, d: i+4, e: i+5, f: i+6, g:i+7};
140
var small = [{a:3, b:2, c:1, d:6, e:7, f:2, g:0}, {a:9, b:8, c:7, d:6, e:7, f:2, g:0}, {a:1, b:2, c:3, d:6, e:7, f:2, g:0},
141
{a:3, b:2, c:1, d:6, e:7, f:2, g:0}, {a:9, b:8, c:7, d:6, e:7, f:2, g:0}, {a:1, b:2, c:3, d:6, e:7, f:2, g:0},
142
{a:3, b:2, c:1, d:6, e:7, f:2, g:0}, {a:9, b:8, c:7, d:6, e:7, f:2, g:0}, {a:1, b:2, c:3, d:6, e:7, f:2, g:0},
143
{a:3, b:2, c:1, d:6, e:7, f:2, g:0}, {a:9, b:8, c:7, d:6, e:7, f:2, g:0}, {a:1, b:2, c:3, d:6, e:7, f:2, g:0}];
145
var testBasic = new Y.Test.Case({
148
{label:"Grandparent", children:[
150
{label:"Parent", children: [
156
cols: [{key:"a", field:"a", label:"AAA", sortable:true, className: ["oneClass", "anotherClass"], width:'75px'},{key:"b", abbr:"bbb", className:"myClass", width: '120px'},{key:"c", width:'75px'},{key:"d", width:'150px'},{key:"3", width:'75px'},{key:"f", width:'150px'},{key:"g", width:'75px'}],
158
cols2: [{key:"a", field:"a", label:"AAA", sortable:true, className: ["oneClass", "anotherClass"], width:'75px'},{key:"b", abbr:"bbb", className:"myClass", width:'75px'},{key:"c"},{key:"d"},{key:"e"},{key:"f"},{key:"g"}],
160
cols3: [{key:"a", field:"a", label:"Lorem Ipsum Dolor SIt Amet", sortable:true, className: ["oneClass", "anotherClass"], width:'5px'},{key:"b", abbr:"Lorem Ipsum Dolor SIt Amet", className:"myClass", width:'75px'},{key:"Lorem Ipsum Dolor SIt Amet"},{key:"Lorem Ipsum Dolor SIt Amet"},{key:"Lorem Ipsum Dolor SIt Amet"},{key:"Lorem Ipsum Dolor SIt Amet"},{key:"Lorem Ipsum Dolor SIt Amet"}],
163
//large or small dataset.
166
//---------------------------------------------
167
// Special instructions
168
//---------------------------------------------
172
//ignore following tests (good to do if you are doing a large dataset)
173
testBaseDatatable: false,
174
testXYDatatable: true,
175
testXDatatable: true,
176
testYDatatable_FixedCol: true,
177
testYDatatable_AutoCol: true,
178
testXYDatatable_BigHeaders: true
182
//---------------------------------------------
183
// Setup and tear down
184
//---------------------------------------------
186
setUp : function () {
189
//this.rs = new Y.Recordset({records:this.initialData});
191
//Some Ways to access recordset properties
192
//Y.log(rs.getRecordByIndex(0).getValue('a'));
193
//Y.log(rs.get('records').length);
196
tearDown : function () {
201
/////////////////////////////////////////////////////////////////////////////
205
/////////////////////////////////////////////////////////////////////////////
209
testBaseDatatable: function() {
211
this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, caption:"Base"});
215
testXYDatatable: function() {
216
var sel = '#scrolling-xy';
217
this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, tdValueTemplate:"plug then render {value}", caption: "ScrollingDataTable"});
218
this.dt.plug(Y.Plugin.DataTableScroll, {width:"200px", height:"300px", scroll:"xy"});
222
testXDatatable: function() {
223
var sel = "#scrolling-x";
225
this.dt = new Y.DataTable.Base({columnset:this.cols2, recordset:this.data, caption:"ScrollingDataTable"});
226
this.dt.plug(Y.Plugin.DataTableScroll, {width:"150px", scroll:"x"});
232
testYDatatable_FixedCol: function() {
233
var sel = "#scrolling-y";
235
this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
236
this.dt.plug(Y.Plugin.DataTableScroll, {height:"300px", scroll:"y"});
240
testYDatatable_AutoCol: function() {
241
var sel = "#scrolling-colwidth";
243
this.dt = new Y.DataTable.Base({columnset:this.cols2, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
244
this.dt.plug(Y.Plugin.DataTableScroll, {height:"250px", scroll:"y"});
248
testXYDatatable_BigHeaders: function() {
249
var sel = "#scrolling-bigcols";
251
this.dt = new Y.DataTable.Base({columnset:this.cols3, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
252
this.dt.plug(Y.Plugin.DataTableScroll, {height:"250px", width:"400px", scroll:"xy"});
260
var suite = new Y.Test.Suite({name:"Datatable Test Suite"});
261
suite.add(testBasic);
263
Y.Test.Runner.setName("Datatable Test Runner");
264
Y.Test.Runner.add(suite);
265
//Y.Test.Runner.run();