<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; Grid</title>
	<atom:link href="http://www.zachleat.com/web/tag/grid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 17:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Faster YUI DataTable with 5 Lines of Code</title>
		<link>http://www.zachleat.com/web/faster-yui-datatable-with-5-lines-of-code/</link>
		<comments>http://www.zachleat.com/web/faster-yui-datatable-with-5-lines-of-code/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 00:34:56 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/12/27/faster-yui-datatable-with-5-lines-of-code/</guid>
		<description><![CDATA[Holy Reflows Batman! The typical usage of a DataTable in the Yahoo User Interface JavaScript library involves passing a string into the constructor signifying the ID attribute of the container you want to attach the DataTable to. However, the YUI DataTable loves the DOM and creating nodes individually using DOM methods. Normally that&#8217;d be fine, [...]]]></description>
			<content:encoded><![CDATA[<p>Holy Reflows Batman!  The typical usage of a DataTable in the Yahoo User Interface JavaScript library involves passing a string into the constructor signifying the ID attribute of the container you want to attach the DataTable to.  However, the YUI DataTable loves the DOM and creating nodes individually using DOM methods.  Normally that&#8217;d be fine, but one of the first things it does in the constructor is create the table element and attach it to the live DOM.  This is a no-no.  Now, every time they append a new node (for a new row or a new cell inside of a row), it causes a reflow in the browser!  What does this mean?  Really bad lag when you insert 40 or 50 rows.  Recognize this piece of code?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myDataTable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;myContainer&quot;</span><span style="color: #339933;">,</span> myColumnDefs<span style="color: #339933;">,</span> myDataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Straight from the docs.  No no no!</p>
<p>Instead, you should pass in an unattached DOM node instead of a string!</p>
<p>Try this code on for size:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myDataTable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> myColumnDefs<span style="color: #339933;">,</span> myDataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'initEvent'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> d <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myContainer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// CHANGE THIS -- match the id of the container you want.</span>
    <span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">firstChild</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> d.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>d.<span style="color: #660066;">firstChild</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// remove previous DataTables</span>
    d.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>._elContainer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/faster-yui-datatable-with-5-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enlarging your YUI DataTable in 29 Seconds or Less!</title>
		<link>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-29-seconds-or-less/</link>
		<comments>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-29-seconds-or-less/#comments</comments>
		<pubDate>Wed, 29 Aug 2007 03:09:48 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Expandable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/08/28/enlarging-your-yui-datatable-in-29-seconds-or-less/</guid>
		<description><![CDATA[This is an updated version of the Enlarging your YUI DataTable in 30 Seconds or Less! modified for the newly released YUI 2.3.0. This method adds an extra row to the YUI DataTable when a row is selected, below the selected row. This allows the developer to add additional content that might not be applicable [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is an updated version of the <a href="http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/">Enlarging your YUI DataTable in 30 Seconds or Less!</a> modified for the newly released YUI 2.3.0.</em></p>
<p>This method adds an extra row to the YUI DataTable when a row is selected, below the selected row.  This allows the developer to add additional content that might not be applicable to the column constraints of a typical datatable or grid and allow that content be displayed more fluidly inside a single row spanning all of the viewable columns.</p>
<p>I know you&#8217;re anxious for an example, so let&#8217;s see some screenshots of a simple YUI DataTable:</p>
<p><a href="http://www.zachleat.com/Lib/ymod/ymod-tableExtension-2.3.0.html"><img src='http://www.zachleat.com/web/wp-content/uploads/2007/08/default-datatable.gif' alt='Default DataTable' /></a></p>
<p>Turns into this when a row is selected:</p>
<p><a href="http://www.zachleat.com/Lib/ymod/ymod-tableExtension-2.3.0.html"><img src='http://www.zachleat.com/web/wp-content/uploads/2007/08/datatable-selected.gif' alt='Row selected' /></a></p>
<p>Click any of the above images for a live example.</p>
<p>Any HTML can be added.  You can make an AJAX call and put the result into the newly inserted row (that will be left as an exercise for the reader [you]).</p>
<p>I know you&#8217;re asking yourself, how the hell do I add this to my YUI DataTable?  WHERE IS THE DAMN SOURCE CODE?  Calm down, you know I&#8217;m getting to it.</p>
<h3>How To</h3>
<p>1. Include the <a href="http://www.zachleat.com/Lib/ymod/ymod-tableExtension-2.3.0.js">ymod-tableExtension-2.3.0.js</a> file.<br />
2. Create your DataTable.  If you don&#8217;t know how to do this, go to the <a href="http://developer.yahoo.com/yui/datatable/">official documentation for help and examples</a>.<br />
3. Make sure your DataTable has the selectionMode parameter set to &#8216;single&#8217;.  This can be achieved by passing in <code>{ selectionMode: 'single' }</code> in as the 4th argument to the DataTable constructor.<br />
4. Use the following code to setup your table extension:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// myDataTable is your DataTable object</span>
YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">tableExtension</span>.<span style="color: #660066;">setup</span><span style="color: #009900;">&#40;</span> myDataTable<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> contentDiv <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> myContent <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> selectedRows <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getSelectedRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> selectedRows.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        myContent <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'Do something based on&lt;br /&gt;the row that is selected!'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    contentDiv.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> myContent<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The setup function is basically a convenience method to add the event listeners.  You can just as easily do this yourself manually:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// myDataTable is your DataTable object.</span>
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'headerRowMousedownEvent'</span><span style="color: #339933;">,</span> YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">tableExtension</span>.<span style="color: #660066;">cleanUp</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'rowClickEvent'</span><span style="color: #339933;">,</span> YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">tableExtension</span>.<span style="color: #660066;">selectRow</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> contentDiv <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009966; font-style: italic;">/* same as function appears above */</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>CSS</h3>
<p>Here&#8217;s some CSS hooks to do some styling.  The expanded row will include the yui-dt-selected class by default.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* The original table row clicked on */</span>
tr.<span style="color: #660066;">ymod</span><span style="color: #339933;">-</span>expanded <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009966; font-style: italic;">/* Row containing the expanded content */</span>
tr.<span style="color: #660066;">ymod</span><span style="color: #339933;">-</span>expandedData <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009966; font-style: italic;">/* Div containing the expanded content inside the row */</span>
tr.<span style="color: #660066;">ymod</span><span style="color: #339933;">-</span>expandedData div.<span style="color: #660066;">ymod</span><span style="color: #339933;">-</span>expandedDataContent <span style="color: #009900;">&#123;</span> background<span style="color: #339933;">-</span>color<span style="color: #339933;">:</span> navy<span style="color: #339933;">;</span> padding<span style="color: #339933;">:</span> 2px 6px<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Limitations</h3>
<p> &#8211; Resorting removes the expanded content.  Otherwise it was messing with the sort.<br />
 &#8211; It only works with single row selection mode, which allows only one row to be selected at a time.  This is not the default (standard), which allows multiple rows to be selected with SHIFT or CTRL.  Feel free to modify this to work with other modes!</p>
<h1><a href="http://www.zachleat.com/Lib/ymod/ymod-tableExtension-2.3.0.js">Download ymod-tableExtension-2.3.0.js</a></h1>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-29-seconds-or-less/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Enlarging your YUI DataTable in 30 Seconds or Less!</title>
		<link>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-30-seconds-or-less/</link>
		<comments>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-30-seconds-or-less/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 02:51:08 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Expandable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/</guid>
		<description><![CDATA[Please note that this post has been updated to the new version of YUI, 2.3.0 in an article called &#8220;Enlarging your YUI DataTable in 29 Seconds or Less!&#8221; Do you want to fit more content onto your DataTable, but don&#8217;t know how? Do you wish that you had fewer columns, or more horizontal screen-estate? Well [...]]]></description>
			<content:encoded><![CDATA[<p><b>Please note that this post has been updated to the new version of YUI, 2.3.0 in an article called <a href="http://www.zachleat.com/web/2007/08/28/enlarging-your-yui-datatable-in-29-seconds-or-less/">&#8220;Enlarging your YUI DataTable in 29 Seconds or Less!&#8221;</a></b></p>
<p>Do you want to fit more content onto your DataTable, but don&#8217;t know how?  Do you wish that you had fewer columns, or more horizontal screen-estate?  Well now you can enlarge your table easily with these simple functions!  Instead of adding more information into additional columns, we have used our patented method of not actually patenting anything to bring you a secret formula that will allow you to dynamically insert rows into your table, designed for holding additional, non-constrained customizable content!</p>
<p>Do you mean to tell me that your formula will give that special lady in your life the DataTable that she has always wanted?</p>
<p>Of course!  In fact, we guarantee this DataTable to satisfy all of the women you know and don&#8217;t know in the world or we&#8217;ll give you a full refund of the purchase price!</p>
<p>Wow! How does it work?</p>
<p><a href="http://www.zachleat.com/Projects/valdi/__test_yui_datatable_expandable.html"></p>
<p>Click here for an example!</p>
<p><img src='http://www.zachleat.com/web/wp-content/uploads/2007/06/datatable.gif' alt='Normal DataTable' /></p>
<p><img src='http://www.zachleat.com/web/wp-content/uploads/2007/06/datatableexpanded.gif' alt='Expanded DataTable' /><br />
</a></p>
<p>When you click on a row in the DataTable, it inserts a child row beneath the row with an HTML string passed in to populate the dynamic content.  When you click on the parent row or the new row that was inserted, the content disappears!  It&#8217;s that easy!  You don&#8217;t have to apply any gross awful smelling creams, or take any large horse-sized pills for this to work!  You literally only use the following code to do it:</p>
<p>Usage Code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myDataTable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;myContainer&quot;</span><span style="color: #339933;">,</span>myColumnSet<span style="color: #339933;">,</span>myDataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cellClickEvent&quot;</span><span style="color: #339933;">,</span> myDataTable.<span style="color: #660066;">onEventSelectRow</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// make sure you're firing the row selection event</span>
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cellClickEvent&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> myCustomHtml <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Hello, this is my expanded content.&lt;br /&gt;:-)&lt;br /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// generate the string, could use an ajax call if you wanted.</span>
   YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">clickAndExpand</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> e<span style="color: #339933;">,</span> myCustomHtml <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// if you do use an ajax call, this function returns a reference to the newly created div that you can put the ajax results into.</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Library Code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'YAHOO.ymod.datatable'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">clickAndExpand</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e<span style="color: #339933;">,</span> expandedHtml <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectedRows <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getSelectedRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> selectedRows.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newRow <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'tr'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newCell <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'td'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newDiv <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newDiv<span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedDataContent'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> expandedHtml <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> newDiv.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> expandedHtml<span style="color: #339933;">;</span>
			newCell.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> newDiv <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			newCell.<span style="color: #660066;">colSpan</span> <span style="color: #339933;">=</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">childNodes</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
			newRow.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> newCell <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nextSibling</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">collapseRow</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> newDiv<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nextSibling</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// pass in the expanded content, NOT the parent row.</span>
YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">collapseRow</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> row <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> row.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> row.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	row.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> row <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Customize the CSS, if desired.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expandedData</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expandedData</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">visible</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr.ymod-<span style="color: #993333;">expanded</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr.ymod-<span style="color: #993333;">expanded</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> div<span style="color: #6666ff;">.ymod-expandedDataContent</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f4f4f4</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">inset</span> <span style="color: #cc00cc;">#aaa</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> zoom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You might even want to put a little + and &#8211; into the first column of each row to give a visual cue that there is more information for display available on click.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/enlarging-your-yui-datatable-in-30-seconds-or-less/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>YUI DataTable and You: Making the Marriage Work</title>
		<link>http://www.zachleat.com/web/yui-datatable-and-you-making-the-marriage-work/</link>
		<comments>http://www.zachleat.com/web/yui-datatable-and-you-making-the-marriage-work/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 22:48:09 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/</guid>
		<description><![CDATA[The DataTable/Grid Component, the ball and chain of GUI components. It doesn&#8217;t let you go out and instantiate beers to create a inebriated subclass of yourself with your friends on Friday night. It makes you do household garbage collection during the last minute of your favorite sporting event. And you&#8217;d think it would die before [...]]]></description>
			<content:encoded><![CDATA[<p>The DataTable/Grid Component, the ball and chain of GUI components.  It doesn&#8217;t let you go out and instantiate beers to create a inebriated subclass of yourself with your friends on Friday night.  It makes you do household garbage collection during the last minute of your favorite sporting event.  And you&#8217;d think it would die before it would ever encapsulate your private class member.  Just to warn you, the previous sentence was not safe for work.</p>
<p>Earlier I published an article entitled <a href="/web/2007/04/04/problems-with-yui-datatable/">Problems with the YUI DataTable</a>.  Now we&#8217;re going to work out those problems together, through better communication and more effective problem solving techniques.  We&#8217;re going to save your marriage.</p>
<p>Earlier I had stated that there were a few problems with the DataTable, in its current form.  Let&#8217;s review (but not play the blame game).</p>
<ul>
<li>Bug #1: Table headers weren&#8217;t lining up correctly in Firefox (personal ignorance on Box Models)</li>
<li>Bug #2: Single Select bug where multiple rows were being selected when column was sorted (All browsers, Sortable and SingleSelect Tables)</li>
<li>Bug #3: Header displayed out of document flow when the window was resized (IE6, Scrollable Tables)</li>
<li>Bug #4: Content was being displayed approximately 60-70 pixels inside the bottom table boundary. (Firefox, Scrollable Tables) Note the position of the &#8216;Top&#8217; links in the test document below.</li>
<li>Bug #5: More of a limitation than a bug, the DataTable does not allow a fixed width table with horizontal overflow.  Say you have a table that you have fixed column widths for, but if the width of the real estate available for the table is less than this minimum, the table should overflow with a scroll bar, but at the same time showing the column headers if you scroll vertically.  A picture is better:<br />
<img src='/web/wp-content/uploads/2007/04/yui-datatable1.gif' alt='Scrollable' /></li>
</ul>
<p>See the following <a href="http://www.zachleat.com/Projects/valdi/__test_yui_datatable_original.html">test document</a> for relevant table tests. (Note that for the purposes of testing, I&#8217;ve decided to test all combinations of the Top 3 DataTable features: scrolling, nested table headers, and sorting)</p>
<p>Just like your favorite professor, now I&#8217;m going to post the <strong>Solutions</strong>:</p>
<p>Bug #1: What is your Box Model?</p>
<p>Use the following JavaScript code to tell if you&#8217;re in Standards Mode or Quirks Mode:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> document.<span style="color: #660066;">compatMode</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'CSS1Compat'</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">'Standards Mode'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Quirks Mode'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Standards mode forces your document into using the W3C Box Model, which is currently the standard.  The W3C Box Model means any width declarations you make in your CSS code will not include padding, border, or margins.  So if you put padding on your table cells and headers, it will need <em>to be added on separately to the total width of your table</em>.</p>
<p>Bug #2: Someone has posted the solution on the <a href="http://sourceforge.net/tracker/index.php?func=detail&#038;aid=1701632&#038;group_id=165715&#038;atid=836476">Sourceforge Bug Tracker here</a>.  (This is included in the DataTable javascript file below)</p>
<p>Bug #3, #4, and #5: I have produced an alternate DataTable file that fixes these bugs using JavaScript code.  All lines that were added or changed are commented with //ADDED or //CHANGED</p>
<p>Developed in and last tested with YUI version 2.2.2.</p>
<p>Download it here:<br />
Full (169 KB): <a href='http://www.zachleat.com/web/wp-content/uploads/2007/04/ymod-datatable-beta.js' title='ymod-datatable-beta.js'>ymod-datatable-beta.js</a><br />
Minimized using <a href="http://www.crockford.com/javascript/jsmin.html">JSMIN</a> (67 KB): <a href='http://www.zachleat.com/web/wp-content/uploads/2007/04/ymod-datatable-beta-min.js' title='ymod-datatable-beta-min.js'>ymod-datatable-beta-min.js</a></p>
<p>The original and minimized YUI DataTable files are 166 KB and 66 KB respectively.</p>
<p>See the <a href="/Projects/valdi/__test_yui_datatable_fluid.html">fluid width DataTables in action here</a>.</p>
<p>A few notes on doing a fixed width DataTable using the code provided above.  The total width of the table body must be 16px less than the width of the header, if you have vertical scrolling (to account for the scrollbar).  So, if the total width of your header is 800px, the total width of your body must be 784px (put the last table cell as 16px smaller).</p>
<p>Here&#8217;s the CSS to go along with a horizontal scrolling DataTable:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.yui-dt-table</span> th<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-table</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> th<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.yui-dt-first</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* table header and only the first row (for drag and drop) */</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> <span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.yui-dt-first</span> td<span style="color: #6666ff;">.yui-dt-last</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">84px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* last table cell (for crappy scrollbar problem) */</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-even</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-odd</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e0dfe0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-selected</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> thead <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#933</span><span style="color: #00AA00;">;</span>color<span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> th a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span> ! important<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-nestedHeaders</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* gotta set this manually, unfortunately */</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* Set your widths! */</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">784px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/yui-datatable-and-you-making-the-marriage-work/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Problems with YUI DataTable</title>
		<link>http://www.zachleat.com/web/problems-with-yui-datatable/</link>
		<comments>http://www.zachleat.com/web/problems-with-yui-datatable/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 22:52:41 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/</guid>
		<description><![CDATA[If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI. So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components. First, I looked [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI.  So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components.  First, I looked at Jack Slocum&#8217;s EXT, which has a nice looking Grid component that had a lot of features I wouldn&#8217;t need, but I didn&#8217;t really want to take a 0.5 MB hit for the limited feature set I was requiring.  Adding the YUI DataTable would only tack on approximately 70-75 KB of additional download.  So first, let me establish what I&#8217;m going for:</p>
<p><strong>Minimum Feature Set</strong>:</p>
<ul>
<li>Client-Side Sorting: I don&#8217;t want it to do an XMLHttpRequest to sort the data, I want it to be done all clientside.</li>
<li>Simple inline editing: Edit a field in the table right there on the table.  I hadn&#8217;t established what types of data I would need to edit yet.</li>
<li>Data Sources: load from a native JavaScript array or a XMLHttpRequest returning XML or JSON.</li>
<li>Data Type Sort Algorithms: at the very minimum different sorting algorithms for numeric columns and string columns.</li>
<li>Hierarchical Columns: group column headers together under a parent header.</li>
<li>Easily customizable: must be able to customize the look and feel of the grid easily using CSS and not by editing Javascript.</li>
<li>Header Freeze: If I have overflow on my table vertically causing a scroll bar, I want the table headers to remain shown at the top of the table while I scroll from top to bottom.</li>
<li>Custom Cell Rendering: I have the data I&#8217;m loading, but I want to change how it looks when it is rendered to the table.  Common for date formatting.</li>
</ul>
<p><strong>Luxury Feature Set</strong>:</p>
<ul>
<li>Resizeable Columns: change the width of a column by dragging on the column header&#8217;s right border.</li>
<li>Movable Columns: dragging a column will cause it to be moved on the table (TIBCO General Interface supports this).</li>
<li>Custom Sort Algorithm: write my own algorithm to specify how data is sorted, or provide a way to do multi-column sorting (sort within one column, ties are sorted by another column, and so on).</li>
<li>Dynamic Paging (don&#8217;t make me click numbered links, load the data automatically when I scroll) both on the client (dynamically insert only what I&#8217;m looking at and remove what I&#8217;ve scrolled past) and using the server (load more data through an XMLHttpRequest)</li>
<li>Column Freeze: if the table is going to scroll horizontally, allow the developer to freeze a column or multiple columns so that they are shown when scrolling from left to right.</li>
</ul>
<p><strong>Evaluation of Options</strong>: How does the YUI DataTable stack up?</p>
<p>Basic Items: Client-Side Sorting, Simple inline editing, Data Sources, Data Type Sort Algorithms (<em>stock types not yet implemented out of the box</em>), Hierarchical Columns, Header Freeze (<em>buggy</em>), Custom Cell Rendering, and is easily customizable with CSS.</p>
<p>Luxury Items: Resizeable Columns, Movable Columns (<em>not supported</em>), Custom Sort Algorithms are supported (you can right your own Data Type Sort Algorithms with this feature), Dynamic Paging (manually, not dynamic), Column Freeze (<em>not supported</em>)</p>
<p>Problems:</p>
<ul>
<li>Any sort of fixed width table is going to be problematic.  Putting a fixed width on the table causes the table headers to be misaligned with the associated table data.  It&#8217;s a mess.  The only viable option here is to let the table do it&#8217;s own width calculations.  You can&#8217;t even set the column widths manually using the {width} variable as suggested when using a fixed width table.</li>
<li>Data Type Sort Algorithms supposedly work from the column type, but this feature is documented in the code as being a TODO.  All columns are sorted by a string datatype, meaning that if your column is numeric and you had the following rows: { 3, 7, 40 }, the sort result would be { 3, 40, 7 }.</li>
<li>Header Freeze was problematic.  Implementing the {scrollable=true} feature as recommended by the documentation causes the table headers to be misaligned with the data in a fixed width table.</li>
<li>Paging uses the old school numbers method.  This wasn&#8217;t a deal breaker, since I classified this feature as a luxury item.</li>
</ul>
<p>Granted, the DataTable in it&#8217;s current form is a beta component, but that 0.5 MB ExtJS hit is looking pretty nice right now.</p>
<p><strong>Minor Update</strong>: to do a fixed width table that will overflow horizontally, this is the method you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#dataTableId</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* change this to whatever id you're using to hold the dataTable */</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">520px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* put in your own fixed width */</span>
	overflow-x<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	overflow-y<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-headtext</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-headcontainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">static</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* without this declaration, the headers weren't horizontally scrolling with the data in IE6 */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/problems-with-yui-datatable/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>

