datatable.html revision a3b15d60042c81a524cebb94370e5a234a19d04b
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<!DOCTYPE HTML>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<html>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<head>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<meta charset="utf-8">
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<title>Datatable Tests</title>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<link rel="stylesheet" type="text/css" href="/build/cssbase/base-min.css">
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<script src="/build/yui/yui-debug.js"></script>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<style>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh html {
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib font-family: sans-serif;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh font-size: smaller;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .message {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh padding: 5px;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh font-size:120%;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh background: #FFFCB6;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh border:1px solid #C9C675;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh #results dt {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh font-weight:bold;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh padding:3px;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh display:block;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh #results dd {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh font-weight:normal;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh color:grey;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
90a3966dd44e306d23febc15ebd65cde07d7a4ddTed Gould #results dd span {
16a8c7d5e433b176636a4a1260c42ea43932110bKrzysztof Kosiński color: red;
54e660c4de9d37185e3953165d053526632ef4f0johanengelen font-weight:bold;
54e660c4de9d37185e3953165d053526632ef4f0johanengelen }
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib</style>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh</head>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<body class="yui3-skin-sam">
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h1>Datatable Tests</h1>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<p>To test the performance of various datatables, look at the following sections in the code:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <pre>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh//large or small dataset.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshdata: large,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
dd69425007680aafc47fdd994e1985625571d252bryce//---------------------------------------------
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh// Special instructions
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh//---------------------------------------------
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh_should: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ignore: {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //ignore following tests (good to do if you are doing a large dataset)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testBaseDatatable: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testXYDatatable: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testXDatatable: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testYDatatable_FixedCol: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testYDatatable_AutoCol: true,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testXYDatatable_BigHeaders: false
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh}
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib </pre>
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh 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>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <hr>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<p><input type="button" value="Run Tests" id="btnRun" disabled=true></p>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <hr>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="results">
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh <h3>Test Results</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh</div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Base Datatable</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="base"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Scrolling XY Datatable (Set columnwidths)</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<P>A general XY scrolling datatable. Column widths are provided for all columns, table width and height is provided.</p>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-xy"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Scrolling X Datatable (Auto Columns)</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<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>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-x"></div>
d444ed610362dab3c3e727d1b110312318b84cb8miklosh
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould<h3>Scrolling Y Datatable</h3>
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould<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>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-y"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Scrolling Datatable with no ColumnWidth</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<p>A Y-scrolling datatable, where only the first 2 columns have a specified width. Only the table height is provided.</p>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-colwidth"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Scrolling Datatable with Big Headers</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<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>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-bigcols"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<h3>Scrolling Datatable with no width or height set</h3>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<p>A scrolling datatable with no width or height values passed in will result in a base datatable being created with auto width and height.</p>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<div id="scrolling-noscroll"></div>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh<script type="text/javascript">
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh(function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh YUI({
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min',
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh allowRollup: false,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh useBrowserConsole: false
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }).use("console", "test", "dump", "datatable", "profiler","node","json-parse", function(Y) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Set up the page
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var ASSERT = Y.Assert,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ARRAYASSERT = Y.ArrayAssert,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh BTNRUN = Y.one("#btnRun"),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh TestRunner = Y.Test.Runner;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh BTNRUN.set("disabled", false);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh TestRunner.subscribe(TestRunner.TEST_CASE_COMPLETE_EVENT, testCompleted);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.on("click", function(e){
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh TestRunner.run();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh BTNRUN.set("value", 'Running...');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh BTNRUN.set("disabled", true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }, BTNRUN);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh function testCompleted() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh BTNRUN.set("value", 'Test Completed');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log('Test Completed');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen var myConsole = new Y.Console().render();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //large data set
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var large = [];
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh for (var i=0; i<500; i++) {
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib large[i] = {a: i+1, b:i+2, c:i+3, d: i+4, e: i+5, f: i+6, g:i+7};
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //small data set
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh 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},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {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},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {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},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {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}];
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var testBasic = new Y.Test.Case({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh name: "API Tests",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh nestedcols: [
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {label:"Grandparent", children:[
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {key: "a"},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {label:"Parent", children: [
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {key:"b"},
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {key:"c"}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ]}
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib ]}
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ],
05a66d0771cb563225b8690de04e9490b35453f2johanengelen 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'}],
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen 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"}],
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen 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"}],
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //large or small dataset.
05a66d0771cb563225b8690de04e9490b35453f2johanengelen data: small,
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //---------------------------------------------
05a66d0771cb563225b8690de04e9490b35453f2johanengelen // Special instructions
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //---------------------------------------------
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen _should: {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen ignore: {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //ignore following tests (good to do if you are doing a large dataset)
05a66d0771cb563225b8690de04e9490b35453f2johanengelen testBaseDatatable: true,
05a66d0771cb563225b8690de04e9490b35453f2johanengelen testXYDatatable: false,
05a66d0771cb563225b8690de04e9490b35453f2johanengelen testXDatatable: false,
05a66d0771cb563225b8690de04e9490b35453f2johanengelen testYDatatable_FixedCol: false,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testYDatatable_AutoCol: false,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testXYDatatable_BigHeaders: false,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testNoScrollDatatablekey: false
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //---------------------------------------------
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Setup and tear down
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen //---------------------------------------------
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh setUp : function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
7cc06cc17ffc875601993118f9533dfe36bd2dd5johanengelen //create recordset
6fb346988965d600415f2a8bbd5af507d82a1418Johan Engelen //this.rs = new Y.Recordset({records:this.initialData});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
7cc06cc17ffc875601993118f9533dfe36bd2dd5johanengelen //Some Ways to access recordset properties
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //Y.log(rs.getRecordByIndex(0).getValue('a'));
68b9e386db1a231abaddbfed4d05f7539bdac786scislac //Y.log(rs.get('records').length);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac },
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac tearDown : function () {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac delete this.dt;
68b9e386db1a231abaddbfed4d05f7539bdac786scislac },
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac /////////////////////////////////////////////////////////////////////////////
68b9e386db1a231abaddbfed4d05f7539bdac786scislac //
68b9e386db1a231abaddbfed4d05f7539bdac786scislac // Displaying Report
68b9e386db1a231abaddbfed4d05f7539bdac786scislac //
68b9e386db1a231abaddbfed4d05f7539bdac786scislac /////////////////////////////////////////////////////////////////////////////
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac displayReport: function(data) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var dl = Y.Node.create('<dl></dl>'),
68b9e386db1a231abaddbfed4d05f7539bdac786scislac results = Y.one('#results');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.each(data, function(v,k,o) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var dt = Y.Node.create('<dt>'+k+'</dt>');
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould var dd = Y.Node.create('<dd>' + v.calls + ' call(s) at ' + v.avg + ' ms/call = <span>' + Math.round(v.avg*v.calls) + '</span> ms total</dd>');
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
05a66d0771cb563225b8690de04e9490b35453f2johanengelen dt.appendChild(dd);
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould dl.appendChild(dt);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen });
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould results.appendChild(dl);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen },
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
68b9e386db1a231abaddbfed4d05f7539bdac786scislac reportParser: function(report) {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac return (report.calls > 0 && report.avg > 0.2);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen },
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen /////////////////////////////////////////////////////////////////////////////
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //
05a66d0771cb563225b8690de04e9490b35453f2johanengelen // Tests
05a66d0771cb563225b8690de04e9490b35453f2johanengelen //
05a66d0771cb563225b8690de04e9490b35453f2johanengelen /////////////////////////////////////////////////////////////////////////////
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould
05a66d0771cb563225b8690de04e9490b35453f2johanengelen testBaseDatatable: function() {
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould var sel = "#base";
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.start('dtBase');
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, caption:"Base"});
54e660c4de9d37185e3953165d053526632ef4f0johanengelen Y.Profiler.registerObject('dt', this.dt);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.dt.render(sel);
05a66d0771cb563225b8690de04e9490b35453f2johanengelen Y.Profiler.stop('dtBase');
05a66d0771cb563225b8690de04e9490b35453f2johanengelen var msg = Y.Profiler.getAverage('dtBase') + 'ms taken to display';
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var report = Y.Profiler.getFullReport(this.reportParser);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.displayReport(report);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.unregisterObject('dt');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.log(msg, "time");
05a66d0771cb563225b8690de04e9490b35453f2johanengelen Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
05a66d0771cb563225b8690de04e9490b35453f2johanengelen },
05a66d0771cb563225b8690de04e9490b35453f2johanengelen
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould testXYDatatable: function() {
05a66d0771cb563225b8690de04e9490b35453f2johanengelen var sel = '#scrolling-xy';
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould Y.Profiler.start('dtXY');
05a66d0771cb563225b8690de04e9490b35453f2johanengelen this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, tdValueTemplate:"plug then render {value}", caption: "ScrollingDataTable"});
7079a43aa387066c2f67402d77dbe3db981b1054Ted Gould Y.Profiler.registerObject('dt', this.dt);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen this.dt.plug(Y.Plugin.DataTableScroll, {width:"200px", height:"300px"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.render(sel);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.stop('dtXY');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var msg = Y.Profiler.getAverage('dtXY') + 'ms taken to display';
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var report = Y.Profiler.getFullReport(this.reportParser);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.displayReport(report);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.unregisterObject('dt');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.log(msg, "time");
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac },
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac testXDatatable: function() {
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var sel = "#scrolling-x";
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.start('dtX');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.dt = new Y.DataTable.Base({columnset:this.cols2, recordset:this.data, caption:"ScrollingDataTable"});
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.registerObject('dt', this.dt);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.dt.plug(Y.Plugin.DataTableScroll, {width:"150px"});
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac this.dt.render(sel);
68b9e386db1a231abaddbfed4d05f7539bdac786scislac Y.Profiler.stop('dtX');
68b9e386db1a231abaddbfed4d05f7539bdac786scislac
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var msg = Y.Profiler.getAverage('dtX') + 'ms taken to display';
68b9e386db1a231abaddbfed4d05f7539bdac786scislac var report = Y.Profiler.getFullReport(this.reportParser);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.displayReport(report);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.unregisterObject('dt');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log(msg, "time");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib testYDatatable_FixedCol: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var sel = "#scrolling-y";
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.start('dtY1');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt = new Y.DataTable.Base({columnset:this.cols, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.registerObject('dt', this.dt);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib this.dt.plug(Y.Plugin.DataTableScroll, {height:"300px"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.render(sel);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.stop('dtY1');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var msg = Y.Profiler.getAverage('dtY1') + 'ms taken to display';
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var report = Y.Profiler.getFullReport(this.reportParser);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.displayReport(report);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.unregisterObject('dt');
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log(msg, 'time');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testYDatatable_AutoCol: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var sel = "#scrolling-colwidth";
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.start('dtY2');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt = new Y.DataTable.Base({columnset:this.cols2, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.registerObject('dt', this.dt);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.plug(Y.Plugin.DataTableScroll, {height:"250px"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.render(sel);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.stop('dtY2');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var msg = Y.Profiler.getAverage('dtY2') + 'ms taken to display';
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var report = Y.Profiler.getFullReport(this.reportParser);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.displayReport(report);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.unregisterObject('dt');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log(msg, 'time');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testXYDatatable_BigHeaders: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var sel = "#scrolling-bigcols";
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.start('dtHeaders');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt = new Y.DataTable.Base({columnset:this.cols3, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.registerObject('dt', this.dt);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.plug(Y.Plugin.DataTableScroll, {height:"250px", width:"400px"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.render(sel);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.stop('dtHeaders');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var msg = Y.Profiler.getAverage('dtHeaders') + 'ms taken to display';
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var report = Y.Profiler.getFullReport(this.reportParser);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.displayReport(report);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.unregisterObject('dt');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.log(msg, 'time');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh testNoScrollDatatable: function() {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var sel = "#scrolling-noscroll";
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.start('dtNoScroll');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt = new Y.DataTable.Base({columnset:this.cols3, recordset:this.data, tdValueTemplate:"plug then render {value}", caption:"ScrollingDataTable"});
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.registerObject('dt', this.dt);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.plug(Y.Plugin.DataTableScroll);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.render(sel);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Profiler.stop('dtNoScroll');
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var msg = Y.Profiler.getAverage('dtNoScroll') + 'ms taken to display';
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var report = Y.Profiler.getFullReport(this.reportParser);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.displayReport(report);
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen Y.Profiler.unregisterObject('dt');
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen Y.log(msg, 'time');
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen Y.one(sel).appendChild('<p class="message">'+msg+'</p>');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh this.dt.scroll.set('width', '200px');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh test_uniqueRecordset: function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Ticket #2529980
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var a = new Y.DataTable.Base(),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh b = new Y.DataTable.Base(),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh aRS = a.get('recordset'),
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib bRS = b.get('recordset');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isTrue(aRS instanceof Y.Recordset);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isTrue(bRS instanceof Y.Recordset);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib Y.Assert.areNotSame(aRS, bRS);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen "caption should not be added to the DOM unless set": function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var container = Y.one("#base"),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table, caption;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table = new Y.DataTable.Base({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh columnset: this.cols,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset: this.data,
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib caption: "Caption set"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table.render(container);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh caption = table.get('boundingBox').one('caption');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isNotNull(caption);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame("Caption set", caption.get('text'));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen table.destroy();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh container.empty(true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table = new Y.DataTable.Base({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh columnset: this.cols,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset: this.data
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table.render(container);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh caption = table.get('boundingBox').one('caption');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isNull(caption);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table.set('caption', 'Caption set');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh caption = table.get('boundingBox').one('caption');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isNotNull(caption);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('Caption set', caption.get('text'));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh "test table.datasource.load() updates UI": function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var data = [ {a:1,b:1,c:1}, {a:2,b:2,c:2}, {a:3,b:3,c:3} ],
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh container = Y.one('#base'),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh source, table;
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen container.empty(true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh source = new Y.DataSource.Local({ source: data });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh source.plug(Y.Plugin.DataSourceArraySchema, {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh resultFields: ['a','b','c']
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib });
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table = new Y.DataTable.Base({
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib columnset: [ { key: 'a', sortable: true }, 'b', 'c' ]
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib });
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib table.plug(Y.Plugin.DataTableDataSource, {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib datasource: source
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould });
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib table.render(container);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould Y.Assert.areSame(0, container.all('tbody tr').size());
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib table.datasource.load();
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib Y.Assert.areSame(3, container.all('tbody tr').size());
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib Y.Assert.areSame('1', container.one('tbody td').get('text'));
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib data[0].a = 'NEW';
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould table.datasource.load();
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould Y.Assert.areSame(3, container.all('tbody tr').size());
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould Y.Assert.areSame('NEW', container.one('tbody td').get('text'));
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould },
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib "test Recordset does not lose plugins on load": function () {
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould var data = [ {a:1,b:1,c:1}, {a:2,b:2,c:2}, {a:3,b:3,c:3} ],
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould container = Y.one('#base'),
479ed85bac2b7467a6678bae572404e33465a5d9acspike recordset,
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould source, table;
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould container.empty(true);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould source = new Y.DataSource.Local({ source: data });
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould source.plug(Y.Plugin.DataSourceArraySchema, {
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould resultFields: ['a','b','c']
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould });
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table = new Y.DataTable.Base({
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib columnset: [ { key: 'a', sortable: true }, 'b', 'c' ]
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould });
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table.plug(Y.Plugin.DataTableDataSource, {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib datasource: source
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib });
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table.plug(Y.Plugin.DataTableSort);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table.render(container);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table.datasource.load();
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould recordset = table.get("recordset");
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould Y.Assert.isObject(recordset);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould Y.Assert.isObject(recordset.sort);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib },
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
09ba3247163582bf2e30e17c4c154aa259ce038acilix "header rows should not have {placeholders}": function () {
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould // Ticket #2530026
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould var data = [ {a:1,b:1,c:1}, {a:2,b:2,c:2}, {a:3,b:3,c:3} ],
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould container = Y.one('#base'),
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib recordset,
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould source, table, html;
3bd80e038b72ad220f218d7053a9089685fab17cTed Gould
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib container.empty(true);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table = new Y.DataTable.Base({
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib recordset: data,
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib columnset: [ 'a', 'b', 'c' ]
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib });
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould table.render(container);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib html = table._theadNode.getContent();
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib Y.Assert.isNull(html.match(/\{\s*\w+\s*\}/));
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib },
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould "cells should default content from column.emptyCellValue": function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Ticket #2529921
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var data = [ {b:1,c:1,d:1},
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak {a:2,c:2,d:2},
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak {a:3,b:3,d:3},
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak {a:4,b:4,c:4} ],
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak container = Y.one('#base'),
1babefb17e4c8157ca2a0f588625a8ac0258dc53buliabyak recordset,
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib source, table;
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib container.empty(true);
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadib
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib table = new Y.DataTable.Base({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset: data,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh columnset: [
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh 'a',
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { key: 'b', emptyCellValue: "(NO B)" },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { key: 'c', formatter: "<em>C: {value}</em>",
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh emptyCellValue: "(NO C)" },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { key: 'd', formatter: function (o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return o.value && (o.value + .5);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh emptyCellValue: "(NO D)" }]
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table.render(container);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isNull(table._tbodyNode
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .getContent().match(/\{\s*\w+\s*\}/));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('', table._tbodyNode.all('tr').item(0)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .all('.yui3-datatable-liner').item(0).getContent());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('(NO B)', table._tbodyNode.all('tr').item(1)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .all('.yui3-datatable-liner').item(1).getContent());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('<EM>C: (NO C)</EM>',
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table._tbodyNode.all('tr').item(2)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .all('.yui3-datatable-liner').item(2).getContent()
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .toUpperCase()); // <-- account for IE UC tags
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('(NO D)', table._tbodyNode.all('tr').item(3)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh .all('.yui3-datatable-liner').item(3).getContent());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib "setting the recordset should update the UI": function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // Ticket #2529920 (comment 18)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // http://yuilibrary.com/projects/yui3/ticket/2529920#comment:18
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var data = [ {a:1,b:1,c:1}, {a:2,b:2,c:2}, {a:3,b:3,c:3} ],
bf7069a487ba218c4542e4adc5497ebd746ab929buliabyak container = Y.one('#base'),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table, cell;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh container.empty(true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table = new Y.DataTable.Base({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset: data,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh columnset: [ 'a', 'b', 'c' ]
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table.render(container);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh cell = table._tbodyNode.one('.yui3-datatable-liner');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.areSame('1', cell.get('text'));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen table.set('recordset', [
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen { a: 10,b: 10,c: 10 },
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen { a: 20,b: 20,c: 20 },
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen { a: 30,b: 30,c: 30 }
e66a49aa774c6770e99591a19873105bfeb5ce74Johan Engelen ]);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh cell = table._tbodyNode.one('.yui3-datatable-liner');
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib Y.Assert.areSame('10', cell.get('text'));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh "formatters should not have access to o.td by default": function () {
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong var table, cells;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh table = new Y.DataTable.Base({
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh columnset: [
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh {
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen key: 'a',
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen formatter: function (o) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Assert.isUndefined(o.td);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh return o.value.toUpperCase();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh 'b',
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { key: 'c', formatter: "({value})" }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ],
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh recordset: [
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { a: "a1", b: 53, c: "c1" },
09ba3247163582bf2e30e17c4c154aa259ce038acilix { a: "a2", b: 35, c: "c2" },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { a: "a3", b: 42, c: "c3" }
6825a6097da27fdfdf22859c0f81c208e7e22bb4Johan Engelen ]
6825a6097da27fdfdf22859c0f81c208e7e22bb4Johan Engelen });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.one('#base').empty();
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould table.render('#base');
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh cells = table._tbodyNode.one('tr').all('td');
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould Y.ArrayAssert.itemsAreSame(
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ['A1', '53', '(c1)'],
09ff61b38270862163a561a7f45acb203db68625Johan Engelen cells.get('text'));
09ff61b38270862163a561a7f45acb203db68625Johan Engelen },
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
025db6f90298127a666cd24bcfc2e22fd35ca84dspeleo "createCell should populate o.td in formatters": function () {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var table, cells, i = 0;
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould table = new Y.DataTable.Base({
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould columnset: [
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould {
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould key: 'a',
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould formatter: function (o) {
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould Y.Assert.isUndefined(o.td);
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould this.createCell(o)
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould .setContent(
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould "<strong>???" + (++i) + "</strong>");
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould Y.Assert.isObject(o.td);
16dc3cff4d07c7f5afdd8c74cf34530b0a6ee93btavmjong }
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib }
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould ],
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak recordset: [{ a: "a1" }, { a: "a2" }, { a: "a3" }]
e9b6af083e34e2397a8ddbe9781920733d09d151Ted Gould });
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński Y.one('#base').empty();
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński table.render('#base');
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak cells = table._tbodyNode.all('td');
d703e5d08553a3dd5eb4f0a11040de79071bdcfbKrzysztof Kosiński
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak Y.ArrayAssert.itemsAreSame(
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak ['???1', '???2', '???3'],
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak cells.get('text'));
ddc1f1d1291eb21b244c7328d260c7d4a43be2fcbuliabyak }
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh var suite = new Y.Test.Suite("Datatable Test Suite");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh suite.add(testBasic);
63d6ddd517060979dd8b8fd41aad3faca7be3c5cTed Gould
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Test.Runner.setName("Datatable Test Runner");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Test.Runner.add(suite);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Y.Test.Runner.run();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh });
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib})();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh</script>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh</body>
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib</html>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh