<?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>My Blog &#187; peter</title>
	<atom:link href="http://www.peterclemons.org/blog/?author=1&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.peterclemons.org/blog</link>
	<description>Software Engineering Topics</description>
	<lastBuildDate>Wed, 08 Aug 2012 15:55:30 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.9.40</generator>
	<item>
		<title>Fetch CSS based on @media queries (not what you think!)</title>
		<link>http://www.peterclemons.org/blog/?p=305</link>
		<comments>http://www.peterclemons.org/blog/?p=305#comments</comments>
		<pubDate>Tue, 07 Aug 2012 22:26:31 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=305</guid>
		<description><![CDATA[Goal Download and apply only the styles I need. Media queries are awesome! They allow me to target CSS rules to very specific solutions. If you&#8217;ve been reading my posts here, you&#8217;ll realize what my ultimate goal is: to produce &#8230; <a href="http://www.peterclemons.org/blog/?p=305">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>Goal</h2>
<p>Download and apply only the styles I need.</p>
<p>Media queries are awesome!  They allow me to target CSS rules to very specific solutions.  If you&#8217;ve been reading my posts here, you&#8217;ll realize what my ultimate goal is:  to produce a single product that runs properly on all targeted devices (desktop browsers, tablets, and smart phones).  And my solution must be fast (light-weight) since mobile devices are still a bit under-powered.</p>
<p>@media queries are commonly part of (within) a CSS file.  For example, in the code below, a width of 743 pixels is assigned to the &#8220;Hello World&#8221; div for only &#8220;screen&#8221; devices with a width of between 801 and 1280 pixels.</p>
<pre>
@media only screen
and (min-width :  801px)
and (max-width : 1280px)
{
   #helloWorld
   {
      width: 743px;
   }
}	
</pre>
<p>Intriguingly, @media queries can also be part of a &lt;link> command.  This is the example we often see when researching how to use @media queries.</p>
<pre>
&lt;link rel="stylesheet" type="text/css" media="screen" href="sans-serif.css">
&lt;link rel="stylesheet" type="text/css" media="print" href="serif.css">
</pre>
<p>This common example suggests that I should segregate my styles into CSS files intended for specific uses.  In my personal project, this is exactly what I&#8217;ve done.  Basically, I&#8217;ve set up 4 style sheets each designated for a specific range of screen widths.</p>
<pre>
&lt;link rel="stylesheet" media="only screen                          and (max-width :  480px)" href="css/layouts/tiny.css" />
&lt;link rel="stylesheet" media="only screen and (min-width :  481px) and (max-width :  800px)" href="css/layouts/small.css" />
&lt;link rel="stylesheet" media="only screen and (min-width :  801px) and (max-width : 1280px)" href="css/layouts/medium.css" />
&lt;link rel="stylesheet" media="only screen and (min-width : 1281px)                         " href="css/layouts/large.css" />
</pre>
<h2>Problem</h2>
<p>Problem is, this code still downloads <font color="red">ALL</font> of the listed CSS files . . . even though I might only need the &#8220;tiny.css&#8221; on a smaller given smart phone.</p>
<p>Clearly, @media queries are not a complete solution since they still fetch all of the CSS files even if I know ahead of time that these CSS files/rules will never be used.</p>
<p>I want a solution that downloads and applies only the required styles for the given situation.</p>
<h2>Solution</h2>
<p>The first question is whether to use the @media queries inside the CSS or in the &lt;link> commands.  The answer is BOTH.</p>
<ul>
<li>You&#8217;ll want them in the &lt;link> commands in order to prevent the fetching of a given CSS file.  <i>More on this later&#8230;</i>
<li>You&#8217;ll also want them inside the CSS files in the event the client downloads multiple CSS files and needs to switch between them.  For example, switching from portrait to landscape orientations might trigger switching from the tiny.css to the small.css rules.
</ul>
<h3>Conditionally fetching CSS files</h3>
<p>I&#8217;ve written a very small snippet of JavaScript that uses the @media queries in the &lt;link> command to only download the CSS files that are relevant to the current device and situation.</p>
<p>This example uses the &#8220;width&#8221; @media query instead of the &#8220;device-width&#8221; for the following reasons:</p>
<ul>
<li>width takes into consideration the &#8220;pixel ratio&#8221;.  For example, a Google Nexus 7 has a device-width of 1280 x 800.  However, it&#8217;s pixel-ratio is 1.33 which means that it reports a CSS resolution of 966 x 603 . . . the resolution the vendor believes is optimal for this device.
<li>width changes based on orientation (orientation is just another resolution!).  The iPad reports a device width of 768 in both portrait and landscape modes.  The @media width value, however, properly changes as orientation is changed.
<li>width affects desktop displays as the browser is resized.  This allows a Web UI on a browser to relayout as necessary based on the current browser size.  Checking @media device-width always reports the same number.
<li>it&#8217;s much easier to base a series of @media statements on width since it doesn&#8217;t need to deal with all of the exceptions in dealing with device-width.
</ul>
<p>This code executes right when the file is loaded, and runs again as needed every time the device&#8217;s orientation changes or the window is resized.</p>
<blockquote><p>NOTE: if the JavaScript method window.matchMedia() is not supported, this code then automatically allows and fetches the specified CSS files.  In other words, it&#8217;s a fail-safe scenario when the conditional download mechanism is not available.</p></blockquote>
<p>This code dynamically fetches only those files that are needed for the current situation &#8230;and downloads additional CSS files as needs change during execution.</p>
<p>Hope this helps!</p>
<pre>
   &lt;script type="text/javascript" language="javascript">
      var head  = document.getElementsByTagName('head')[0];
      var links = document.getElementsByTagName('link');

      //Prevent adding the same &lt;link> more than once
      function hasLink ( cssURL )
      {
         for ( x = 0; x < links.length; x++ )
         {
            var href = links[x].getAttribute ( "href" );
            if ( (typeof(href) != 'undefined') &#038;&#038; (href === cssURL) )
               return true;
         }
         return false;
      }

      //Include CSS if Media Query matches or @media examination is not supported
      function includeCSS ( mediaQuery, cssURL )
      {
         var deviceQuery = window.matchMedia( mediaQuery );
         if ( (deviceQuery.matches == true) || (typeof(window.matchMedia) === 'undefined') )
         {
            if ( hasLink ( cssURL ) == false )
            {
               var link = document.createElement('link');
                   link.href = cssURL;
                   link.rel  = 'stylesheet';
                   link.type = 'text/css';
               head.appendChild(link);
            }
         }
      }

      function evaluateLayoutCSS()
      {
         includeCSS ( "only screen                          and (max-width :  480px)", "css/layouts/tiny.css"  );
         includeCSS ( "only screen and (min-width :  481px) and (max-width :  800px)", "css/layouts/small.css" );
         includeCSS ( "only screen and (min-width :  801px) and (max-width : 1280px)", "css/layouts/medium.css");
         includeCSS ( "only screen and (min-width : 1281px)                         ", "css/layouts/large.css" );
      }
      evaluateLayoutCSS(); //Run early at least once
   
      //Register events to recalculate the media queries on orientation and size changes
      window.onorientationchange = function() { evaluateLayoutCSS() };
      window.onresize            = function() { evaluateLayoutCSS() };
   &lt;/script> 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=305</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using JavaScript to read @media values</title>
		<link>http://www.peterclemons.org/blog/?p=256</link>
		<comments>http://www.peterclemons.org/blog/?p=256#comments</comments>
		<pubDate>Sat, 04 Aug 2012 03:14:45 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=256</guid>
		<description><![CDATA[As most Web developers already know, using @media queries in combination with %-based (or em-based) values in your CSS is the best way of presenting your Web pages optimally on a variety of output devices such as desktop displays, mobile &#8230; <a href="http://www.peterclemons.org/blog/?p=256">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As most Web developers already know, using @media queries in combination with %-based (or em-based) values in your CSS is the best way of presenting your Web pages optimally on a variety of output devices such as desktop displays, mobile phones, and tablets.</p>
<h1>Responsive Web Sites</h1>
<p>For those of you who don&#8217;t know what I&#8217;m talking about, check out these fine example sites.  To see what I mean, click on a picture to load them into a browser window.  Then slowly change the size of the browser and watch how these Web sites handle differences in screen size.</p>
<p>You&#8217;ll note that they dynamically change font and images sizes, and even completely change layouts, all based on the browser&#8217;s display size.  </p>
<p>The point is that these sites look great all the way from a huge desktop screen down to the smallest smart phone display.  That&#8217;s what we&#8217;re after.</p>
<h4>OWLTASTIC</h4>
<p><a href="http://owltastic.com/"><img alt="" src="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/owltastic.jpg" class="alignnone" width="510" height="268" /></a></p>
<h4>Deren K</h4>
<p><a href="http://www.deren.me/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/derenk.jpg" class="alignnone" width="510"/></a></p>
<h4>Boston Globe</h4>
<p><a href="http://www.bostonglobe.com"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/responsive.jpg" class="alignnone" width="510"/></a></p>
<h4>About.com</h4>
<p><a href="http://www.about.com"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/about.jpg" class="alignnone" width="510"/></a></p>
<h1>Inconsistent @media Values</h1>
<p>As I set out to define my CSS files, my simple @media queries weren&#8217;t always working. Unfortunately, I quickly realized that I couldn&#8217;t just use &#8220;@media max-device-width:320px&#8221; and other increasing pixel values to define the range of devices I was going to support.</p>
<p>Bottom line, the expected results from the @media queries were not consistent across the various devices.  For example:</p>
<ul>
<li>While most devices report the &#8220;@media device-width&#8221; based on the current orientation of the device, the iPad for some reason always reports its width as 768px in both landscape and portrait orientations!
<li>While most devices report the &#8220;@media device-width&#8221; as the actual number of pixels that make up the width of the device, some devices report a value less than the actual number of pixels in order to present a larger view to the user.  For example the iPad 3&#8242;s display is physically 1536 x 2048.  However, it reports a value of 768px for the &#8220;@media device-width&#8221; value.
</ul>
<h2>Determining Actual @media Values for a Device</h2>
<p>In order to create @media queries that isolate the range of devices I want to support, I needed to learn the values devices actually report for the various @media queries.</p>
<p>I hoped (assumed) I&#8217;d just find some simple Web page that I could load on each of the devices I was targeting and it would tell me the device&#8217;s actual values.</p>
<p>Turns out I was very wrong!</p>
<p>After a lot of Googling around, not only does this very useful Web page not exist (at least I can&#8217;t find it), but JavaScript can&#8217;t directly access these values either!  So I can&#8217;t easily write my own page as a solution.</p>
<h2>Problem</h2>
<p>As of this writing, there are currently no properties on the window or screen objects to access the values examined by the @media queries. In other words, I can&#8217;t just &#8220;alert(&#8216;Device Width: &#8216;+screen.deviceWidth)&#8221; to display all of the @media values.<br />
<i style="font-size:.8em;">Turns out a few are available, but I can&#8217;t be 100% certain they&#8217;re the same as the @media queries</i></p>
<p>Clearly, I can &#8220;test&#8221; against a given @media value.  For example, I can write window.matchMedia( &#8220;min-device-width:768px&#8221; ), and this will return true for all devices that are 768 pixels wide or larger.</p>
<p>However, I can&#8217;t easily report what the device&#8217;s actual pixel width is.  For example, my desktop screen is currently 1600 pixels wide, but would also match this query.  In some cases, I could use &#8220;other&#8221; older JavaScript-accessible properties, but I specifically want to know how the @media values are reported since this is how I&#8217;m going to code my CSS.</p>
<h2>Solution</h2>
<p>I have created a simple Web page that you can load into any browser on any device, and it will directly report the value of each of the device&#8217;s @media queries.</p>
<p>It does this by simply testing every value until a value reports true.  For example, for determining the device&#8217;s &#8220;@media device-width&#8221; value, it tests every value from 0 to 4000, and in the case of my desktop stops once it reaches 1600.</p>
<p>Clearly, there is a distinct speed issue here &#8230;especially if I examine 15 or 20 properties.  To speed things up, I&#8217;ve created a set of &#8220;likely&#8217; values for each property.  For example, when reporting on the &#8220;@media color&#8221; value, I pass in [8,10,12,16,24,32] as likely tests.  If this list fails, then it will test every value from 0 to 4000.  In most cases, the likely values are used.  In a few cases &#8212; usually when a browser doesn&#8217;t support a given @media query &#8212; it&#8217;ll take a bit longer &#8230;but no more than 5 seconds or so.</p>
<p>It&#8217;s a work-in-progress.  As I get to using it on more devices, I&#8217;ll refine, add, update as necessary.  But for now, this should do quite well.</p>
<p>Hope it helps you too.</p>
<div style=font-size:.8em>BTW, after this analysis I ended up creating the following style sheets.  For more details on this, and a much better dynamic implementation, see my post entitled <a href="http://www.peterclemons.org/blog/?p=305">Fetch CSS based on @media queries (not what you think!)</a>.</p>
<pre>
&lt;link rel="stylesheet" media="only screen                          and (max-width :  480px)" href="css/layouts/tiny.css" />
&lt;link rel="stylesheet" media="only screen and (min-width :  481px) and (max-width :  800px)" href="css/layouts/small.css" />
&lt;link rel="stylesheet" media="only screen and (min-width :  801px) and (max-width : 1280px)" href="css/layouts/medium.css" />
&lt;link rel="stylesheet" media="only screen and (min-width : 1281px)                         " href="css/layouts/large.css" />
</pre>
</div>
<p><br style="height:30px;"><br />
<a style="font-size:1.3em;" href="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/mediaqueries.html" title="Detect device media values" target="_blank">See your device&#8217;s @media values now</a>.</p>
<p>Here&#8217;s what the output looks like</p>
<p><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/08/mediaqueries.jpg" class="alignnone" /></p>
<p style="height:75px" />
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=256</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to support JSON-P on the server</title>
		<link>http://www.peterclemons.org/blog/?p=251</link>
		<comments>http://www.peterclemons.org/blog/?p=251#comments</comments>
		<pubDate>Tue, 31 Jul 2012 22:32:59 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[Everything Else]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=251</guid>
		<description><![CDATA[Just a quick note for how to modify a standard JSON reply to support requesting data across domains The answer here is really quite simple &#8230;if the &#038;callback=something parameter is provided, then: //JSONP opening if ( callback != null ) &#8230; <a href="http://www.peterclemons.org/blog/?p=251">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Just a quick note for how to modify a standard JSON reply to support requesting data across domains</p>
<p>The answer here is really quite simple &#8230;if the &#038;callback=something parameter is provided, then:</p>
<pre>
    //JSONP opening
    if ( callback != null )
        jsonBuf.append ( callback + "(" );
    
    //Beginning of standard reply
    JSON data
    //End of standard reply
    
    //JSONP closure
    if ( callback != null )
        jsonBuf.append ( ");" );
</pre>
<p>If you&#8217;re like most people, and JSON-P is being considered long after all of your REST end-points have already been created, then coding a method that simply wraps the existing REST replies within the &#8220;something( normal rest reply );&#8221; construct is a very fast way of supporting cross-browser scripting for rest clients.</p>
<ul>
<li>It appears there&#8217;s a performance penalty for using JSON-P instead of straight JSON replies.  See <a href="http://jsperf.com/ajax-jsonp-vs-ajax-json">http://jsperf.com/ajax-jsonp-vs-ajax-json</a> for more information.
<li>Just FYI, Jersey already supports JSON-P with a simple annotation of the REST end-points, and a minor wrapping of the reply as noted above.  Further, Jersey recognizes the application/x-javascript mine type to return a JSON-P response without requiring the &#038;callback= query parameter.
<li>JSON-P is a mature enough technology that JQuery, Dojo, YUI, MooTools, Windows WCF, Sencha Touch, IBM BPM, and most other relevant web client and server products now support it.
<li>Our chosen DataTables also supports JSON-P with the following modification:
<pre>
"fnServerData": function( sUrl, aoData, fnCallback, oSettings )
{
   oSettings.jqXHR = $.ajax(
   {
      "url"       : sUrl,
      "data"      : aoData,
      "dataType"  : "jsonp",
      "cache"     : false,
      "success"   : fnCallback
   } );
}
</pre>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=251</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New Kind of Stylesheet</title>
		<link>http://www.peterclemons.org/blog/?p=187</link>
		<comments>http://www.peterclemons.org/blog/?p=187#comments</comments>
		<pubDate>Tue, 31 Jul 2012 06:59:29 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=187</guid>
		<description><![CDATA[Adding Variables to&#160;CSS Goal Make it MUCH easier for customers to brand Web-based products Note that the primary goal here is NOT to make it easier for developers to create CSS files. The primary goal is for CUSTOMERS to more &#8230; <a href="http://www.peterclemons.org/blog/?p=187">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h1 style="font-size:3em; line-height: 1.2em; text-align:center; margin-bottom:-125px; position:relative; z-order:1">Adding Variables to&nbsp;CSS</h1>
<p style="text-align:center">
<img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/css.jpg" alt="" />
</p>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; margin-top:-50px; position:relative; z-order:1">Goal</h1>
<p style="text-align:right; font-size:2em;">
<img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/Goal.jpg" alt="" style="float:left;" /><br />
<span style="position:relative; top:-30px;">Make it MUCH easier <strong>for customers</strong> to brand Web-based products</span>
</p>
<blockquote><p>Note that the primary goal here is NOT to make it easier for developers to create CSS files.  The primary goal is for CUSTOMERS to more easily modify CSS files.  In other words, even though we could modify CSS in much more dramatic ways to make it easier for developers to create these files, the goal here is not developers, rather end users.  So, the CSS file needs to remain as user friendly and familiar as possible while still making it much easier to brand the CSS.</p></blockquote>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; position:relative; z-order:1">Problem Statement</h1>
<p style="text-align:right; font-size:2em;">
<img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/problem-die2.jpg" alt="" style="float:left;" /></p>
<div style="position:relative; top:-30px; left:20px;">
<ul>
<li>CSS files usually contain hundreds of color and font codes
<li>Color and font codes that should be the same are sometimes slightly different.  E.g., dark gray is sometimes #333333; sometimes #313233.  Dumb.
<li>It&#8217;s very difficult for customers to find, understand, and properly change these codes
</ul>
<p>We need to find a solution that makes it easier for customers to modify our CSS files without having to hunt-and-peck for the relevant colors codes.
</p></div>
</p>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; position:relative; z-order:1">Solution 1</h1>
<p style="text-align:right; font-size:2em;">
<a href="http://lesscss.org/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/Less.png" alt="" style="float:left;padding-bottom:20px;" /></a></p>
<div style="position:relative; top:-30px; left:20px;">
<ul>
<li>A wonderful package supporting all of the latest proposed CSS features such as variables, mixins, operations, functions
<li>I&#8217;d love to use this package.  However:
<ul>
<li>it is written in JavaScript and therefore requires <a href="http://nodejs.org/">Node.js</a> and <a href="http://www.mozilla.org/rhino/">Rhino</a>
<li>that&#8217;s 68MB worth of files I need to lay down on customers&#8217; computers
<li>over > 5000 files
<li>from Java, would have to do an external execution in order to compile our CSS files
<li>Even if I automated this work, it&#8217;s an awful lot to ask of customers just to have variables in CSS
</ul>
</ul>
<p>I can&#8217;t use Less because I need to find a solution that consumes very little resources to compile the CSS
</p></div>
</p>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; position:relative; z-order:1">Solution 2</h1>
<p style="text-align:right; font-size:2em;">
<a href="http://sass-lang.com/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/Sass.jpg" alt="" style="float:left; margin-left:-100px;margin-right:-150px;" /></a></p>
<div style="position:relative; top:-30px; left:20px;">
<ul>
<li>Like Less, a package supporting all of the latest proposed CSS features including variables, mixins, operations, functions, nested rules, conditional expressions, and more.
<li style="margin-bottom:100px;">From a developer&#8217;s perspective, this is the package I&#8217;d choose (I think it&#8217;s slightly better than Less).</li>
<li>However I can&#8217;t for many of the same reasons as Less:
<ul>
<li>it is written in <a href="http://www.ruby-lang.org/en/">Ruby</a> (a great language) and therefore requires a Ruby interpreter on customers&#8217; computers
<li>For a Windows environment, that&#8217;s 30MB worth of files I need to lay down on customers&#8217; computers
<li>over > 93,000 files
<li>and like Less, I&#8217;d still have to do a slow, external execution environment offering little control over the compilation of our CSS files
<li>Even if I automated this work, it&#8217;s an awful lot to ask of customers just to have variables in CSS
</ul>
</ul>
<p>I can&#8217;t use Sass because it requires Ruby and lots of resources to compile the CSS.  I need something that is light-weight, preferably runs in Java, and allows me to make tweaks should I need to.
</p></div>
</p>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; position:relative; z-order:1">What&#8217;s Coming in CSS</h1>
<div style="text-align:center; margin-top:-40px; margin-bottom:-80px;">
<a href="http://lesscss.org/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/w3c.gif"></a>
</div>
<p style="text-align:left; font-size:2em;">
<ul>
<li>CSS Variables is already in draft form
<ul>
<li><a href="http://dev.w3.org/csswg/css-variables/">http://dev.w3.org/csswg/css-variables/</a>
   </ul>
</li>
<li>CSS Mixins is currently in proposal form
<ul>
<li><a href="http://dev.w3.org/csswg/css-variables/">http://dev.w3.org/csswg/css-variables/</a>
   </ul>
</li>
<li>Variables, mixins, and nesting are already in WebKit (in an experimental form)
<ul>
<li><a href="http://johanbrook.com/design/css/webkit-css-variables-mixins-nesting/">http://johanbrook.com/design/css/webkit-css-variables-mixins-nesting/</a>
<li><a href="http://www.webmonkey.com/2012/06/css-variables-webkit-brings-the-css-jackalope-to-life/">http://www.webmonkey.com/2012/06/css-variables-webkit-brings-the-css-jackalope-to-life/</a>
   </ul>
</li>
</ul>
<p>Looks like whatever solution I find, it&#8217;s going to be somewhat temporary since the W3C is already under way to add some of these awesome features into CSS.</p>
<p>
The ideal solution would not only be easy to use for customers, but would also easily migrate to the standard solution once that&#8217;s fully supported by all browsers in a year or two.</p>
<p>
Seeing that the goal is to make it easy for customers to brand our CSS, the ideal solution will look as much like standard css as possible.  In other words, it will NOT use all these new Less and Sass CSS features.  Bare minimum is best.
</p>
<p/>
<h1 style="font-size:3em; text-align:center; margin-bottom:-5px; position:relative; z-order:1">Solution 3</h1>
<p style="text-align:left; font-size:2em;">
<div style="position:relative; top:-30px;">
<a href="http://sass-lang.com/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/zuss.png" style="float:left; margin-right:40px; width:250px; padding-bottom:20px;" /></a></p>
<ul>
<li><a href="http://code.google.com/p/zuss/">ZUSS</a> is a pure Java package; that&#8217;s good already since that means it can be part of my standard development environment.  I can use either the jar directly, or modify the source code as needed.
<li>It&#8217;s tiny
<ul>
<li>89K  (Wow!! &#8212; compare that to Less and Sass above)
<li>73 files in 1 jar  (again Wow!)
   </ul>
</li>
<li>ZUSS supports most of the new CSS features the other packages support:
<ul>
<li>Variables
<li>Mixins
<li>Nested Rules
<li>Functions
<li>Includes
<li>Conditional Expressions
   </ul>
</li>
<li>ZUSS provides a small servlet that compiles the CSS files on demand (when requested from the browser)
<ul>
<li>This allows our CSS to be either in a War file (which is how Web products are usually distributed) or in an external directory where customers could copy and edit the files.
<li>Caches CSS for future requests
<li>Recompiles as CSS files are changed
   </ul>
</li>
<li>ZUSS is licensed under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser GPL</a> which means it&#8217;s very developer and distribution friendly
</ul>
</div>
<p style="margin-top:125px; text-align:left; font-size:2em;">
<div style="position:relative; top:-30px; left:20px;">
<a href="http://sass-lang.com/"><img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/LetsDemo.png" alt="" style="float:left; width:550px; padding-bottom:20px;" /></a>
</div>
<h2>Fonts</h2>
<p>Here&#8217;s how a font is defined in my new CSS:</p>
<pre>
@global-font-family()
{
   font-family: Helvetica, Arial, sans-serif;
}
</pre>
<p>Notice that it begins with an @ symbol.  This designates a variable in the ZUSS language.  In other words, global-font-family() becomes a mixin when used.</p>
<p>Notice also that global-font-family() contains a full CSS attribute declaration:  font-family: Helvetica, Arial, sans-serif;  &nbsp;&nbsp;&nbsp;We could have included any number of other attribute definitions, for example size, color, margins, line height, font weight and style, etc.  Anything placed within the braces is included when used elsewhere in the CSS file.</p>
<p>Here&#8217;s the mixin used elsewhere in the CSS:</p>
<pre>
.welcomeHeader
{
   @global-font-family();
   font-size: 2em;
}
</pre>
<p>Sweet !!</p>
<h2>Colors</h2>
<p>Here&#8217;s how a color is defined in my new CSS:</p>
<pre>
@product-color: #8cc63f; /* product name in nav bar, links, quote bin header, active button background, slider value, bread crumb sep */
</pre>
<p>Any time I want to use that color, I simply:</p>
<pre>
.headerLogoText
{
   color: @product-color;
}
</pre>
<h2>Functions</h2>
<p>If you paid attention to the comment in the color variable defined above, you&#8217;ll note we&#8217;re using that same color in lots of areas throughout the product.  A good 15 places use that color directly, as is.  However, buttons have gradients, hovers, and pressed states.  Links change colors when hovered or visited.</p>
<p>And we&#8217;d like to use a &#8220;faint&#8221; version of the color when selecting items in rows.  Rather than having the customer specify all the variants of a given color, wouldn&#8217;t it be cool if we could automatically &#8220;derive&#8221; the color from the primary color.  That way, all the customer has to specify is a single color &#8230;and none of its variants.</p>
<p>ZUSS offers two kinds of functions to do this type of task:</p>
<ul>
<li>A simple function defined in CSS permitting basic math functions and color manipulations
<pre>@lighten(@color, @diff: 10%): @color * (1 + @diff);</pre>
</li>
<li>Java-defined functions that can be called directly by our CSS and can provide any range of sophistication
<pre>@lighten(@color, @diff: 10%): @import com.netiq.agility.client.internal.ColorUtils;</pre>
</li>
</ul>
<p>We chose to go with the more sophisticated Java-based functions permitting more accurate color calculations.</p>
<ul>
<li>Here&#8217;s our <a href="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/ColorUtils.java_.txt">ColorUtils.java</a> class in which we created a series of high-fidelity color rendering methods
<li>These are based on the HSB (Hue, Saturation, Brightness) color model which is also supported by the basic Java Color class and by Photoshop.
<ul>
<li>It&#8217;s much easier to make a color brighter by simply adjusting the &#8220;brightness&#8221; factor than trying to calculate Red, Green, and Blue values.
   </ul>
</li>
</ul>
<h2>Derived Colors</h2>
<p>Now that we have color variables and high-fidelity color manipulation routines, let me show you what we did for the single &#8220;product color&#8221; which I think you&#8217;ll agree most Web interfaces have:</p>
<pre>
/* User-provided Colors */
@product-color:                     #8cc63f;   /* product name in nav bar, links, quote bin header, active button background, slider value, bread crumb sep */

/* Derived Colors - users do NOT need to edit these colors */
@product-color-lighter:             @lighten   ( @product-color, 15% );
@product-color-darker:              @darken    ( @product-color, 15% );

@product-color-hover:               @highlight ( @product-color, "-92%" );
@product-color-hover-lighter:       @lighten   ( @product-color-hover, 3% );
@product-color-hover-darker:        @darken    ( @product-color-hover, 5% );

@product-color-select:              @highlight ( @product-color, "-78%" );
@product-color-select-lighter:      @lighten   ( @product-color-select, 3% );
@product-color-select-darker:       @darken    ( @product-color-select, 5% );

/* hover */
@active-bhover-color:               white;
@active-bhover-background-color:    @lighten   ( @product-color, 10% );
@active-bhover-background-start:    @lighten   ( @active-bhover-background-color, 5%);
@active-bhover-background-end:      @darken    ( @active-bhover-background-color, 12%);
@active-bhover-border:              @darken    ( @active-bhover-background-color, 15%);
@active-bhover-shadow-color:        @shadow    ( @active-bhover-background-end );

/* pressed */
@active-bdown-color:                black;                                          /* invert the hover color */
@active-bdown-background-color:     @darken    ( @product-color, 5% );
@active-bdown-background-start:     @active-bhover-background-end;                  /* invert the hover color */
@active-bdown-background-end:       @active-bhover-background-start;                /* invert the hover color */
@active-bdown-border:               @darken    ( @active-bdown-background-color, 12% );
@active-bdown-shadow-color:         @shadow    ( @active-bdown-background-end );
</pre>
<p>We&#8217;ve created 20 variants on the primary user-provided &#8220;Product Color&#8221;.  These 20 colors are then used throughout the CSS whenever a product-color-related accent is desired.</p>
<ul>
<li>Links (normal, hover, visited)
<li>Buttons (gradients for normal, hover, pressed)
<li>Product logo
<li>Header colors
<li>Scroll bar thumb
<li>Bread crumb separators
<li>Triggers in various UI widgets (combo, spinner, date picker, etc.)
<li>List selection and hover
<li>many other UI elements use versions of the product color !
</ul>
<p>In all, there are hundreds of places throughout the CSS where these 21 colors are used.</p>
<p>I think you&#8217;ll agree, that&#8217;s a lot of benefit for the customer &#8230;and they only had to define 1 color value to do so !!!</p>
<p>Note that in our final implementation, we ask the user to define approximately 15 primary colors in a single location at the top of the CSS file.  And that&#8217;s it.  Press refresh in your browser, and the entire color scheme changes throughout.</p>
<h2>Includes</h2>
<p>To make our files even simpler, we used ZUSS&#8217;s include ability to hide our function declarations and derived color definitions in separate include files that our customers will never see as they edit the CSS to make their own Themes.</p>
<pre>
@include functions.ncss;
@include derived_colors.ncss;
</pre>
<p><h1 style="font-size:3em; line-height: 1.2em; text-align:center; margin-bottom:15px; margin-top:75px; position:relative; z-order:1">Provide a Theming Generator</h1>
<p style="text-align:left;">
Come to think of it, now that our CSS is sssssoooooooo simple, we could very easily produce a simple dialog within our product that allows the user to define the colors right from the UI &#8230;rather than having to find/copy/edit/save the CSS in the file system.</p>
<p>This &#8220;Theme Creator&#8221; dialog would be very simple to create.  Just ask for a small set of color and font definitions, show examples of each in action, ask for a Theme name, and that&#8217;s it.</p>
<p>I&#8217;ll leave this for a future exercise to blog about.
</p>
<p style="height:100px" />
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=187</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>So, which table is best?</title>
		<link>http://www.peterclemons.org/blog/?p=175</link>
		<comments>http://www.peterclemons.org/blog/?p=175#comments</comments>
		<pubDate>Tue, 10 Jul 2012 16:12:18 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=175</guid>
		<description><![CDATA[I propose DataTables is the best choice for any project wanting to provide a single solution for both desktop and mobile devices. While both jqGrid and DataTables are excellent technology and both meet the &#8220;good enough&#8221; criteria, DataTables has a &#8230; <a href="http://www.peterclemons.org/blog/?p=175">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I propose DataTables is the best choice for any project wanting to provide a single solution for both desktop and mobile devices.</p>
<p>While both jqGrid and DataTables are excellent technology and both meet the &#8220;good enough&#8221; criteria, DataTables has a slight edge for mobile devices.<br />
<br />
<i style="font-size:85%;">* note that <a href="http://www.peterclemons.org/blog/?p=161">SlickGrid</a> was eliminated as a candidate.</i></p>
<h1>Here are my reasons for proposing DataTables:</h1>
<ul>
<li>DataTables has a smoother scrolling algorithm on mobile devices (iPad 3)
<ul>
<li><a href="http://www.youtube.com/watch?v=MzvrqdZs2fo">Video of jqGrid</a> scrolling on an iPad 3
<li><a href="http://www.youtube.com/watch?v=qtlFWE7YI2g">Video of DataTables</a> scrolling on an iPad 3
   </ul>
<li>DataTables auto-eliminates the scroll bar and uses the device&#8217;s scrolling method
<li>jqGrid&#8217;s styling is more heavily bound to JQuery UI, creating greater conflict as we try to be JQuery Mobile compliant
<li>DataTables implements Virtual Rendering &#8230;deferring draw calls until needed
<li>By Default, DataTables download size is considerably smaller: 25K vs 68K
<li>DataTables has an excellent unit test suite comprising over 2800 tests
<li>DataTables provides over 130 pre-built examples
<li>DataTables provides a nicer ability to &#8220;expand&#8221; a row to show additional detail
</ul>
<p>
Of course, jqGrid also has some advantages over DataTables.  However, we do not need these in our current solution.  For more details, see the <a href="http://www.peterclemons.org/blog/?p=121">jqGrid Evaluation</a> post.<br /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=175</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using DataTables with ThemeRoller &#8211; Mobile styles</title>
		<link>http://www.peterclemons.org/blog/?p=95</link>
		<comments>http://www.peterclemons.org/blog/?p=95#comments</comments>
		<pubDate>Fri, 06 Jul 2012 23:42:13 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=95</guid>
		<description><![CDATA[Since our project requires a single code base for both desktop and mobile clients, the list we choose needs to look good in both places. Ideally, we could limit ourselves to just the JQuery-Mobile styles, and it would look good &#8230; <a href="http://www.peterclemons.org/blog/?p=95">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<style>
DIV.blog>ul>li {margin-left:0px;}
DIV.blog>ul>li:first-child {margin-top:-20px;}
DIV.blog>ul>li blockquote {line-height:105%; font-size:95%; margin-top:0px; margin-left:0px; margin-bottom:-17px;}
DIV.blog blockquote {line-height:105%; font-size:95%; margin-top:-20px; margin-left:0px; margin-bottom:0px; padding-bottom:3px;}
</style>
<div class="blog">
Since our project requires a single code base for both desktop and mobile clients, the list we choose needs to look good in both places.  Ideally, we could limit ourselves to just the JQuery-Mobile styles, and it would look good on both.  This post attempts to investigate that objective:</p>
<h1>Useful Links</h1>
<ul>
<li><strong>Doc</strong> &#8211; <a href="http://jquerymobile.com/test/index.html">http://jquerymobile.com/test/index.html</a>
<li><strong>ThemeRoller</strong> &#8211; <a href="http://jquerymobile.com/themeroller/">http://jquerymobile.com/themeroller/</a>
<li><strong>List Content formatting</strong> &#8211; <a href="http://jquerymobile.com/test/docs/lists/lists-formatting.html">http://jquerymobile.com/test/docs/lists/lists-formatting.html</a>
</ul>
<h1>What styles apply to a list?</h1>
<p>Here&#8217;s my first attempt at styling a DataTables table using JQuery-Mobile styles<br />
<img src="http://www.peterclemons.org/blog/wp-content/uploads/2012/07/DataTables-Theming-Just-Learning.jpg"></p>
<p>Ignore how ugly it looks &#8230;I&#8217;m just learning about JQuery-Mobile styles, and I&#8217;m trying lots of different things in this image all at once.</p>
<blockquote><p><strong>NOTE 1:</strong> I have not yet redefined the style definitions in my Theme-Roller produced stylesheet.  That&#8217;s why it looks so ugly.</p></blockquote>
<blockquote><p><strong>NOTE 2:</strong> I tried letting JQuery-Mobile apply its styles based on the data-role type attributes &#8230;but you&#8217;ll note that doesn&#8217;t seem to work for a dynamically-produced table</p></blockquote>
<blockquote><p><strong>NOTE 3:</strong> For now, I&#8217;m using swatch &#8220;A&#8221; from my stylesheet.  Not quite sure yet if I&#8217;ll want to create a swatch just for tables or not.  For now, I&#8217;m thinking no &#8230;each swatch could redefine the table&#8217;s appearance.</p></blockquote>
<h1>Here&#8217;s what I learned</h1>
<h2>JQuery Mobile &#8211; Applying the correct List styles</h2>
<ul>
<li>For now anyways, the closest thing to tables JQuery-Mobile has support for is &#8220;lists&#8221;
<li>Therefore, I applied the following styles which are the same styles JQuery-Mobile lists use:
<ul>
<li><strong>table headings</strong> &#8211; ui-li ui-bar-a
<li><strong>rows (&lt;tr&gt;)</strong> &#8211; ui-li ui-btn ui-btn-up-a
<li><strong>row hovers</strong> &#8211; ui-btn-hover-a
<li><strong>Heading data in cells</strong> &#8211; ui-li-heading
<li><strong>Normal text in cells</strong> &#8211; ui-li-desc
<li><strong>Bolded data in cells</strong> &#8211; just use &lt;strong&gt; around text within the ui-li-desc div
<li>I still need to style the pagination control.  I will probably use DataTable&#8217;s various $.fn.dataTableExt.oStdClasses.* variables to do that.
<ul>
<li>I guess on that note, you&#8217;ll find that I set the &#8220;bJQueryUI&#8221; flag to false
<li>JQuery UI&#8217;s styles just conflict too much with JQuery-Mobile&#8217;s styles
      </ul>
</ul>
</li>
</ul>
<h2>Making Changes to the List style definitions</h2>
<ul>
<li>I also updated some of the styles in my ThemeRoller-produced style sheet
<ul>
<li>added ui-bar-a:hover &#8211; to give a hover effect on the column headers
   </ul>
</li>
</ul>
<h2>JQuery Mobile &#8211; &#8220;Data-Role&#8221; Attributes</h2>
<ul>
<li>I also had to mess around with a few other things to get it to behave properly within a JQuery-Mobile environment
<ul>
<li>just to be proper, I added the &#8220;ui-listview&#8221; style to the DataTables table object
<li>likewise, I added the data-role of &#8220;listview&#8221;
<li>I had to redefine the display attribute for rows to table-row
<li>and did the same thing for header rows:  display:table-row;
   </ul>
</li>
<li>Note the <strong>data-icon=&#8217;arrow-r&#8217;</strong> text in the bar above the table.  See the little &#8220;right arrow&#8221; icon at the far-right of the bar.  Seems to work fine.
<ul>
<li>Now take a look at the same text in each row&#8217;s &#8220;Name&#8221; column.  The text is there, but the actual icon isn&#8217;t.
<li>In other words, I can&#8217;t seem to get JQuery-Mobile to dynamically render my styles within the table.  More on this in a future post I suspect <img src="http://www.peterclemons.org/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" />
   </ul>
</li>
</ul>
<h1>DataTables &#8211; sDOM &#8211; moving things around</h1>
<ul>
<li>Take a look at the navigation and search bars &#8230;they&#8217;re way at the top of the screen
<ul>
<li>That&#8217;s because I created my own &lt;div&gt;s and wanted to move these controls elsewhere in the document
<ul>
<li> var search = $(&#8216;.dataTables_filter&#8217;); $(&#8216;#search&#8217;).append ( search );
<li> var navBar = $(&#8216;.dataTables_paginate&#8217;); $(&#8216;#page_nav_bar&#8217;).append ( navBar );
      </ul>
</li>
<li>Why didn&#8217;t I just use sDOM to move things around?
<ul>
<li> Because sDOM can only create the various DataTable controls above or below the table (even both).
<li> But it cannot create them disconnected from the table.  In my case, I will have other controls between the table&#8217;s search box and the table itself.
<li> I think using JQuery&#8217;s append() method to move things around is quite nice &#8230;except it does this after the items are already attached to the DOM &#8230;this might be a flicker or speed issue.  More on this later&#8230;
      </ul>
</ul>
</li>
</ul>
<p></blog></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=95</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SlickGrid Evaluation</title>
		<link>http://www.peterclemons.org/blog/?p=161</link>
		<comments>http://www.peterclemons.org/blog/?p=161#comments</comments>
		<pubDate>Fri, 06 Jul 2012 04:44:13 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=161</guid>
		<description><![CDATA[SlickGrid Links - Home: https://github.com/mleibman/SlickGrid/wiki - Examples: https://github.com/mleibman/SlickGrid/wiki/Examples - AJAX paging: http://mleibman.github.com/SlickGrid/examples/example6-ajax-loading.html - Used By: https://github.com/mleibman/SlickGrid/wiki/Used-by NOTE A full evaluation of this product was not performed. Although I spent as much time in the evaluation as the other tables, I &#8230; <a href="http://www.peterclemons.org/blog/?p=161">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<style>
DIV.blog>ul>li {margin-left:0px;}
DIV.blog>ul>li:first-child {margin-top:-20px;}
DIV.blog>ul>li blockquote {line-height:105%; font-size:95%; margin-top:0px; margin-left:0px; margin-bottom:-17px;}
DIV.blog blockquote {line-height:105%; font-size:95%; margin-top:-20px; margin-left:0px; margin-bottom:0px; padding-bottom:3px;}
</style>
<div class="blog">
<h1>SlickGrid Links</h1>
<p>- Home: <a href="https://github.com/mleibman/SlickGrid/wiki">https://github.com/mleibman/SlickGrid/wiki</a><br />
- Examples: <a href="https://github.com/mleibman/SlickGrid/wiki/Examples">https://github.com/mleibman/SlickGrid/wiki/Examples</a><br />
- AJAX paging: <a href="http://mleibman.github.com/SlickGrid/examples/example6-ajax-loading.html">http://mleibman.github.com/SlickGrid/examples/example6-ajax-loading.html</a><br />
- Used By: <a href="https://github.com/mleibman/SlickGrid/wiki/Used-by">https://github.com/mleibman/SlickGrid/wiki/Used-by</a></p>
<h1>NOTE</h1>
<p>A full evaluation of this product was not performed.  Although I spent as much time in the evaluation as the other tables, I determined that SlickGrid is no longer a candidate for our use.</p>
<h1>Here&#8217;s what I learned:</h1>
<p>1) SlickGrid is primarily designed around the &#8220;paging via scroll bar&#8221; mechanism.  Actually, to be even more precise, it&#8217;s really &#8220;rendering via scroll bar&#8221;.  SlickGrid primarily attempts to load all records into JavaScript, then defers rendering of those records until they&#8217;re scrolled into view.</p>
<p>2) SlickGrid does have a remote paging capability as seen in <a href="http://mleibman.github.com/SlickGrid/examples/example6-ajax-loading.html">Example 6</a>.  However, almost all of its examples, and most of its add-ons, are geared around the concept that everything&#8217;s already loaded into Javascript variables.  When using server-side paging, it does offload the filtering and sorting to the server.</p>
<p>3) <a href="http://mleibman.github.com/SlickGrid/examples/example4-model.html">Example 4</a>, the <a href="http://mleibman.github.com/SlickGrid/examples/example-grouping">Grouping Example</a>, and the <a href="http://mleibman.github.com/SlickGrid/examples/example-optimizing-dataview.html">Optimized DataView Example</a> show a paging navigator control (enabled via the small icon at bottom-right).  However, examples do not exist for server-side paged data.</p>
<ul>
<li> The current Slick.Controls.Pager widget (which produces the nav bar) was intended for use with the DataView class.  The DataView class, in turn, was designed to work with fully-loaded data.  Hence, the navigation bar cannot at this time be used with AJAX- loaded data.  There are people who have gotten it to work with various hacks, but this is not yet part of this library.
</ul>
<p>4) SlickGrid does NOT use &lt;table&gt;&lt;tr&gt;&lt;td&gt; codes.  Instead, it uses a series of div&#8217;s<br />
5) SlickGrid is not as mature, well supported, or well documented as jqGrid or DataTables</p>
<p>============================================================</p>
<h1>Evaluation</h1>
<p>In order to properly evaluate jqGrid, DataTables, and SlickGrid against our &#8220;good enough&#8221; criteria, I set up a test REST server that returns &#8220;real&#8221; JSON data.  The server contains a list of over 10,000 objects.</p>
<p>While the data is real, the response time is not.  The test REST server pre-fetches all real data from back-end services, then cache&#8217;s that data internally in order to eliminate server response time in the evaluation.  While real server calls are measured in 10ths of seconds, my test REST server&#8217;s average response time is 3ms for any given page of 50 objects.</p>
<p>I had to create unique REST end-points for each of my tables in this evaluation because each uses different parameters to control the list behavior.  They all pull from the same list of cached objects.</p>
<p>I created a test html file &#8212; /SlickGrid/slickgrid.html &#8212; which creates a SlickGrid table and loads Users (50 at a time from a set of 10,000) from a SlickGrid-specific REST end-point.</p>
<p>1) Performance is #1</p>
<ul>
<li> performance of fetching remote data is outstanding &#8230;just like the other table controls
<li> 50 records:  desktop, round-trip is 3ms, iPad3 it&#8217;s about .3s &#8211; .5s
<li> 500 records:  <not tested>
<li> SlickGrid implements Virtual Rendering preventing the drawing of a given row until it is scrolled into view
<li> SlickGrid is capable of post-rendering work.  For example, filling a given cell with a value from the server even after the row&#8217;s been scrolled into view.  Here&#8217;s an example. Post-rendering takes place only when the UI is idle.  Rows are processed 1-by-1.
</ul>
<p>2) Device requirements: performance and functionality will be determined by ICS-based tablets, not older Honeycomb devices, not smart phones</p>
<ul>
<li> As noted above, performance on an iPad3 is outstanding
</ul>
<p>3) Table paging and navigation will be performed by next, prev, first, last, and #&#8217;s links</p>
<ul>
<li> SlickGrid does not provide a navigation control for ajax-loaded data since it is primarily a page-via-scrollbar solution
<li> Turns out the current Slick.Controls.Pager widget (which produces the nav bar) was intended for  use with the DataView class.  The DataView class, in turn, was designed to work with fully-loaded data.  Hence, the navigation bar cannot at this time be used with AJAX-loaded data.  There are people who have gotten it to work with various hacks, but this is not yet part of this library.
</ul>
<p>4) The table will load 1 &#8220;page&#8221; of data at a time, if the rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page</p>
<ul>
<li> SlickGrid&#8217;s loads 1 &#8220;page&#8221; of data at a time.  Previously loaded data is cached.
<li> However, it does not provide a navigation control.  Hence, the only pagination is via the scroll bar.
<li> If the fetched rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page
<li> The table can be sized such that it grows as needed to accommodate all rows
</ul>
<p>5) The table will not cache previous requests (to protect mobile devices; and if #1 is met, no need)</p>
<ul>
<li> SlickGrid by default CACHE&#8217;s previous requests
<li> Uncertain if this can be turned off
</ul>
<p>6) All paging, filtering, sorting will be performed by the back-end; none in the client</p>
<ul>
<li> SlickGrid can be set up to paging, filtering, and sorting in both the UI and the back-end
<li> However, SlickGrid&#8217;s DataView (required for using the navigation widget) is only available for fully-loaded data (not AJAX data)
<li> When loading AJAX data, SlickGrid performs paging, filtering, and sorting by the back-end
</ul>
<p>7) We will filter on only string data originating from the server for now</p>
<ul>
<li> Unexamined
</ul>
<p>8) Code size should not exceed 200K (minified and gzip&#8217;d); the smaller the better</p>
<ul>
<li> Unexamined
</ul>
<p>9) We will only select a mature, well supported Table widget. We will not make our own.</p>
<ul>
<li> Current version: 2.0.1, actively developed
<li> This product does not appear to be as mature, as well supported, or as well documented as jqGrid or DataTables
</ul>
<p>10) Theming Support :</p>
<ul>
<li> Unexamined
</ul>
<p>11) Table must by stylable as in our mockups</p>
<ul>
<li> Unexamined
<li> Every cell can be given a specific style name.  Hence, I believe the table is stylable
<li> <a href="http://mleibman.github.com/SlickGrid/examples/example8-alternative-display.html">SlickGrid</a> is able to use <a href="http://ejohn.org/blog/javascript-micro-templating/">John Resig&#8217;s micro-templates</a> while still using SlickGrid&#8217;s virtual rendering technology
</ul>
<p>12) Single select for Marketplace; likely multi-select for future</p>
<ul>
<li> SlickGrid supports single selection via row-selection or checkboxes
<li> multi-select with checkboxes &#8230;but mostly unexamined
</ul>
<p>13) In-row actions for Marketplace; likely top-of list actions for future</p>
<ul>
<li> SlickGrid supports any buttons we&#8217;d like to place in a row
<li> SlickGrid is capable of post-rendering work.  For example, filling a given cell with a value from the server even after the row&#8217;s been scrolled into view.  Here&#8217;s an example. Post-rendering takes place only when the UI is idle.  Rows are processed 1-by-1.
</ul>
<p>14) No in-cell editing for now</p>
<ul>
<li> SlickGrid does support in-cell editing, however this can easily be turned off
</ul>
<p>15) No &#8220;View As&#8230;&#8221; alternate views for now</p>
<ul>
<li> SlickGrid does not directly support alternate views for its tables
</ul>
<p>16) No conclusion on table width handling. However, the survey says most people would like to see columns shrink until it&#8217;s ridiculous, then hide low-priority columns altogether</p>
<ul>
<li> Columns can be fixed or proportionally sized
<li> Data within the cells shows ellipses if cell contents exceed cell size
</ul>
<p>17) The table needs to support a distribution-friendly license</p>
<ul>
<li> SlickGrid is licensed under the MIT
</ul>
<p></blog></p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=161</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jqGrid Evaluation</title>
		<link>http://www.peterclemons.org/blog/?p=121</link>
		<comments>http://www.peterclemons.org/blog/?p=121#comments</comments>
		<pubDate>Thu, 05 Jul 2012 01:47:55 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=121</guid>
		<description><![CDATA[Test REST Server In order to properly evaluate jqGrid, DataTables, and SlickGrid against our &#8220;good enough&#8221; criteria, I set up a test REST server that returns &#8220;real&#8221; JSON data. The server contains a list of over 10,000 objects. While the &#8230; <a href="http://www.peterclemons.org/blog/?p=121">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<style>
DIV.blog>ul>li {margin-left:0px;}
DIV.blog>ul>li:first-child {margin-top:-20px;}
DIV.blog>ul>li blockquote {line-height:105%; font-size:95%; margin-top:0px; margin-left:0px; margin-bottom:-17px;}
DIV.blog blockquote {line-height:105%; font-size:95%; margin-top:-20px; margin-left:0px; margin-bottom:0px; padding-bottom:3px;}
</style>
<div class="blog">
<p><strong>Test REST Server</strong><br />
In order to properly evaluate jqGrid, DataTables, and SlickGrid against our &#8220;good enough&#8221; criteria, I set up a test REST server that returns &#8220;real&#8221; JSON data.  The server contains a list of over 10,000 objects.</p>
<p>While the data is real, the response time is not.  The test REST server pre-fetches all real data from back-end services, then cache&#8217;s that data internally in order to eliminate server response time in the evaluation.  While real server calls are measured in 10ths of seconds, my test REST server&#8217;s average response time is 3ms for any given page of 50 objects.</p>
<p>I had to create unique REST end-points for each of my tables in this evaluation because each uses different parameters to control the list behavior.  They all pull from the same list of cached objects.</p>
<h1>jqGrid Links</h1>
<p>- Home: <a href="http://www.trirand.com/blog/">http://www.trirand.com/blog/</a><br />
- Wiki: <a href="http://www.trirand.com/jqgridwiki/doku.php">http://www.trirand.com/jqgridwiki/doku.php</a><br />
- Examples: <a href="http://www.trirand.com/blog/jqgrid/jqgrid.html">http://www.trirand.com/blog/jqgrid/jqgrid.html</a><br />
- Addl Examples: <a href="http://www.trirand.net/demo.aspx">http://www.trirand.net/demo.aspx</a><br />
- Code: <a href="http://www.trirand.com/blog/jqgrid/downloads/jqgrid_demo38.zip">http://www.trirand.com/blog/jqgrid/downloads/jqgrid_demo38.zip</a><br />
- Column Model: <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options">http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options</a><br />
- Params: <a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options">http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options</a><br />
- Themes: <strong>NOTE:</strong> jqGrid uses <a href="http://jqueryui.com/themeroller/">jQuery UI &#8211; ThemeRoller</a> to style its table.  This could be a problem for us because JQuery UI and JQuery-Mobile don&#8217;t play well together.  We&#8217;ll see&#8230;<br />
- Commercial Web Site: <a href="http://www.trirand.net/">http://www.trirand.net/</a></p>
<h1>Evaluation</h1>
<p>I created a test html file which creates a jqGrid table and loads 50 objects at a time from the REST end-point mentioned above. Remember, it&#8217;s a cache&#8217;d list.</p>
<p>1) Performance is #1</p>
<ul>
<li>Like DataTables, performance is outstanding &#8230;actually, when fetching records, it&#8217;s identical because it&#8217;s the same back-end
<li>50 records:  desktop, round-trip is 3ms, iPad3 is about .3s &#8211; .5s
<li>500 records:  desktop, round-trip is 15ms, iPad3 is about 1s
<li>Unlike SlikGrid and DataTables, jqGrid does not implement Virtual Rendering.  As far as I can tell, it renders the full result set as soon as it&#8217;s received.  Don&#8217;t know how much of a performance hit this is, but it could be a big deal depending on what you put in your cells.
<li>However, with jqGrid&#8217;s gridview parameter, it is able to &#8220;append&#8221; all the rows with a single call &#8230;making it a very fast operation.  Note that this choice comes with some limitations:  for example, no afterInsertRow event, etc.
<li>I do not like how jqGrid handles the scroll bar on an iPad3.  While it appropriately hides the scroll bar, the table does NOT take over the available space.  Further, when scrolling, it does not use the iPad3&#8242;s &#8220;thin&#8221; scroll bar.  Finally, when fast swiping, it stops scrolling immediately after you&#8217;ve quit touching &#8230;to smooth scroll stop like you&#8217;d expect.
</ul>
<p>2) Device requirements: performance and functionality will be determined by low-powered, ICS-based tablets, not older Honeycomb devices, nor smart phones</p>
<ul>
<li>As noted above, performance on an iPad3 is outstanding
<li>Performance on a Honeycomb smart phone (Galaxy S2 on T-Mobile) is acceptable (but not part of our required criteria)
</ul>
<p>3) Table paging and navigation will be performed by next, prev, first, last, and #&#8217;s links</p>
<ul>
<li>jqGrid supports both paging-via-navigation-controls and paging-via-scrollbar
<li>Here&#8217;s an example: Can do this: <a href="http://trirand.com/blog/jqgrid/jqgrid.html">http://trirand.com/blog/jqgrid/jqgrid.html</a> look at Advanced/Master Detail
</ul>
<p>4) The table will load 1 &#8220;page&#8221; of data at a time, if the rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page</p>
<ul>
<li>jqGrid will load 1 &#8220;page&#8221; of data at a time
<li>If the fetched rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page.  Note my &#8220;scrolling&#8221; comments in the Performance section above.
<li>The table can be sized such that it grows as needed to accommodate all rows
</ul>
<p>5) The table will <strong>not</strong> cache previous requests (to protect mobile devices; and if #1 is met, no need)</p>
<ul>
<li>jqGrid by default does not cache previous requests
<li>I am uncertain if jqGrid can be set up to pre-fetch addl pages or not ??????
</ul>
<p>6) All paging, filtering, sorting will be performed by the back-end; none in the client</p>
<ul>
<li>jqGrid supports paging, filtering, and sorting in both the UI and the back-end
</ul>
<p>7) We will filter on only string data originating from the server for now</p>
<ul>
<li>According to its doc, developers can specify sorting for various types including string, number, boolean, link, select and percent.  However, I believe this is for client-side processing only, and is not part of ajax-based solutions.
</ul>
<p>8) Code size should not exceed 200K (minified and gzip&#8217;d); the smaller the better</p>
<ul>
<li>File size: File size: CSS: 12K;  JS 430K raw / 270K minified / 68K  gzip&#8217;d;
<li>3 times larger than DataTables
</ul>
<p>9) We will only select a mature, well supported Table widget. We will not make our own.</p>
<ul>
<li>jqGrid is currently in version 4.4.0 (released in June 2012)
<li>and has been developed now for at least 3 years, since 2009 &#8230;but I actually suspect much longer since that was version 3.5.x
<li>has over 8,500 threads (27,000 posts) in its on-line forums
<li>Unknown number of unit tests &#8230;I&#8217;m uncertain how rock-solid this product is.  Probably pretty good.
<li>It does not provide very many pre-built examples &#8230;but the ones that are there suffice
</ul>
<p>10) Theming Support :</p>
<ul>
<li>DataTables supports ONLY JQuery UI ThemeRoller classes
<li>However, with the rich set of overridable events, I believe we could add/remove any styles we want &#8230;just like DataTables
</ul>
<p>11) Table must by stylable to may our particular look and feel</p>
<ul>
<li>jqGrid does not specifically provide APIs to apply the styles we want throughout the table.  However, with the rich set of overridable events, I believe it can be styled to match our needs &#8230;just like DataTables.
<li>jqGrid provides a very rich Column Renderer which is passed the backing row Object and the property value &#8230;giving the renderer the opportunity to display addl fields in each cell
<li>jqGrid does not really permit row expansion showing more details about a row Object.  Any examples I&#8217;ve seen add additional rows &#8230;kinda klunky.
</ul>
<p>12) Row selection (single select for now; multi-select for future)</p>
<ul>
<li>jqGrid supports single selection via row-selection or checkboxes
<li>I do not believe jqGrid supports multi-select across page boundries like DataTables does.  Not sure I care though either
</ul>
<p>13) Links / Actions &#8211; in-row actions for now; likely top-of list actions for future</p>
<ul>
<li>With its column renderers, jqGrid supports placing any data into a cell, including buttons/actions
<li>jqGrid will use any specified Object value (for example: id) as the row&#8217;s ID attribute
<li>jqGrid supports a very rich set of custom events which code can bind to
</ul>
<p>14) Editing: no in-cell editing for now</p>
<ul>
<li>jqGrid supports in-cell / in-row editing
<li>2 method exist: see &#8220;Row Editing -> In-Line Navigator&#8221; and &#8220;Live Data Manipulation -> Navigator&#8221; examples
</ul>
<p>15) Alternate Views: no &#8220;View As&#8230;&#8221; alternate views for now</p>
<ul>
<li>jqGrid does not directly support alternate views for its tables
</ul>
<p>16) No conclusion on table width handling. However, most people would like to see columns shrink until it&#8217;s ridiculous, then hide low-priority columns altogether</p>
<ul>
<li>A jqGrid table normally sizes to the combined widths of its visible columns
<li>However, you can also set the grid width, and the columns will adjust accordingly
<li>I have not seen any example where the table&#8217;s width sizes dynamically.  Seems to always be based on the grid&#8217;s &#8220;set Width&#8221;
<li>Data within a jqGrid cell by default does NOT wraps unto addl lines (However, I&#8217;m sure we could easily change this with the CSS whitespace property).  By default, when a cell&#8217;s data exceeds the cell bounds, ellipses show&#8230;
<li>Uncertain if jqGrid could auto-show/hide low priority columns based on table width
</ul>
<p>17) The table needs to support a distribution-friendly license</p>
<ul>
<li>jqGrid is licensed under the free MIT license
<li>However, they have also launched an official commercial website <a href="http://www.trirand.net">http://www.trirand.net</a>
</ul>
<h1>Special Notes</h1>
<ul>
<li> jqGrid supports a truly awesome Column Model
<li> I&#8217;m not too impressed with its &#8220;row&#8221; editor &#8230;adequate, but not beautiful.  Of course, we can style any way we want.
<li> I don&#8217;t know why jqGrid&#8217;s &#8220;row expansion&#8221; feature simply adds more rows.  In my testing, I learned that I can place any amount of data into each cell, independent of the other cells.  In other words, rows can have variable row height, and I could auto-expand the current row if I wanted to. I think they should specifically make an &#8220;expand&#8221; feature for rows to show addl detail.
<li> jqGrid supports a grid within a grid!
<li> jqGrid support a &#8220;tree&#8221; control by adding additional rows with indented values.  Kinda cool!.  Check out the &#8220;simple&#8221; example at: <a href="http://www.trirand.net/demotreephp.aspx">http://www.trirand.net/demotreephp.aspx</a>
<li> jqGrid has launched an official commercial website <a href="http://www.trirand.net">http://www.trirand.net</a>.  Check it out; there are some impressive demos there.  You&#8217;ll note that they&#8217;ve spent considerable time trying to make a list and tree out of the same control.  IOW, if you need a tree control, this is one is pretty good.
</ul>
<h1>Notable Params</h1>
<p>- 100 params<br />
- 20 Events<br />
- over 50 Triggered Events !!</p>
<pre>
ajaxGridOptions  - override all AJAX parameters including: error, complete, and beforesend events
altclass         - specify the class you want for the "alternate/zebra" rows.  Hmmm ...do they have this for all styles?
autowidth        - table auto-sizes (width) according to the size of its parent div
cellEdit         - enable editing
cellsubmit       - when editing, determine where the edits are saved (remote or clientArray/local)
colModel         - array which describes the parameters of the columns
deepempty        - uses JQuery to empty a row; prevents memory leaks
direction        - good support for Right-to-Left and Left-to-Right languages
forceFit         - all columns will always consume 100% of the table width (adjacent columns adjust as needed)
hoverrows        - enable row hover effects
idPrefix         - add a prefix to a row's ID
loadui           - control what to do while loading: disabale, enable, block
mtype            - HTTP GET or POST
pager            - enable paging controls.  <strong>NOTE:</strong> this also controls into what HTML div to place the pager
pgtext           - show details about the current list
prmNames         - controls the names of all the parameters sent to the server
scroll           - tells jqGrid to disable paging controls and to enable paging-via-scrollbar
shrinkToFit      - recalculate column widths as the table shrinks
sortable         - uses JQuery UI to permit reordering of the columns.  Since we're trying to be JQuery Mobile compliant, we do not want this.
toolbar          - defines the tools available in the toolbar
treeGrid         - enable the "tree" aspects of the grid control
url              - the source of the ajax data
userData         - addl data to make part of the request
afterInsertRow   - method gets called after a row is created
beforeRequest    - before a request is made
beforeProcessing - after a response is received (but before doing anything with it)
gridComplete     - after all received data is fully processed
onPaging         - after selecting a paging options, but before processing the data
resizeStop       - fires after resizing event has taken place (resizeStart also)
tons and tons of other options and events
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=121</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DataTables Evaluation</title>
		<link>http://www.peterclemons.org/blog/?p=70</link>
		<comments>http://www.peterclemons.org/blog/?p=70#comments</comments>
		<pubDate>Sun, 01 Jul 2012 06:56:52 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=70</guid>
		<description><![CDATA[Test REST Server In order to properly evaluate DataTables against our &#8220;good enough&#8221; criteria, I set up a test REST server that returned &#8220;real&#8221; JSON data. The server contains a list of over 10,000 objects. While the data is real, &#8230; <a href="http://www.peterclemons.org/blog/?p=70">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<style>
DIV.blog>ul>li {margin-left:0px;}
DIV.blog>ul>li:first-child {margin-top:-20px;}
DIV.blog>ul>li blockquote {line-height:105%; font-size:95%; margin-top:0px; margin-left:0px; margin-bottom:-20px;}
DIV.blog blockquote {line-height:105%; font-size:95%; margin-top:-20px; margin-left:0px; margin-bottom:0px;}
</style>
<div class="blog">
<strong>Test REST Server</strong><br />
In order to properly evaluate DataTables against our &#8220;good enough&#8221; criteria, I set up a test REST server that returned &#8220;real&#8221; JSON data.  The server contains a list of over 10,000 objects.</p>
<p>While the data is real, the response time is not.  The test REST server pre-fetches all real data from back-end services, then cache&#8217;s that data internally in order to eliminate server response time in the evaluation.  While real server calls are measured in 10ths of seconds, my test REST server&#8217;s average response time is 3ms for any given page of 50 objects.</p>
<p><strong>DataTables</strong><br />
- Home: <a href="http://datatables.net/">http://datatables.net/</a><br />
- Examples: <a href="http://www.datatables.net/examples/">http://www.datatables.net/examples/</a><br />
- Tests: <a href="https://github.com/DataTables/DataTables/tree/master/media/unit_testing">https://github.com/DataTables/DataTables/tree/master/media/unit_testing</a><br />
- Params: <a href="http://datatables.net/ref">http://datatables.net/ref</a> (125 params supported)<br />
- Themes: <a href="http://datatables.net/styling/themes/ui-darkness">http://datatables.net/styling/themes/ui-darkness<br />
</a></p>
<p>I created a test html file which creates a DataTables table and loads 50 objects at a time from the REST end-point mentioned above. Remember, it&#8217;s a cache&#8217;d list.</p>
<p>1) Performance is #1</p>
<ul>
<li>performance is outstanding
<li>50 records:  desktop, round-trip is 3ms, iPad3 is about .3s &#8211; .5s
<li>500 records:  desktop, round-trip is 15ms, iPad3 is about 1s
<li>Like SlikGrid, DataTables implements Virtual Rendering with its bDeferRender parameter Rendered rows/cells are retained for 1-page scrolling
<li>I like how it handles the scroll bar on an iPad3.  With no addl coding, it auto hides the bar, and lets the table take over the available space.  Further, when scrolling, I like how it uses the iPad3&#8242;s &#8220;thin&#8221; scroll bar.  Finally, it uses the device&#8217;s fast swipe gesture to continue to scroll the list even after you&#8217;ve quit touching; obviously it stops after a second or two &#8230;just as you&#8217;d expect.
</ul>
<p>2) Device requirements: performance and functionality will be determined by low-powered, ICS-based tablets, not older Honeycomb devices, nor smart phones</p>
<ul>
<li>As noted above, performance on an iPad3 is outstanding
<li>Performance on a Honeycomb smart phone (Galaxy S2 on T-Mobile) is acceptable (but not part of our required criteria)
</ul>
<p>3) Table paging and navigation will be performed by next, prev, first, last, and #&#8217;s links</p>
<ul>
<li>DataTables supports both paging-via-navigation-controls, and paging-via-scrollbar
</ul>
<p>4) The table will load 1 &#8220;page&#8221; of data at a time, if the rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page</p>
<ul>
<li>DataTables will load 1 &#8220;page&#8221; of data at a time
<li>If the fetched rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page
<li>The table can be sized such that it grows as needed to accommodate all rows
</ul>
<p>5) The table will <strong>not</strong> cache previous requests (to protect mobile devices; and if #1 is met, no need)</p>
<ul>
<li>DataTables by default does not cache previous requests
<li>DataTables can be set up to pre-fetch addl pages as needed
</ul>
<p>6) All paging, filtering, sorting will be performed by the back-end; none in the client</p>
<ul>
<li>DataTables supports paging, filtering, and sorting in both the UI and the back-end
</ul>
<p>7) We will filter on only string data originating from the server for now</p>
<ul>
<li>DataTables has made some effort to support sorting and filtering on representations of the data other than what&#8217;s displayed (Enums vs their string implementation; dates; etc.) However, I believe this is for client-side processing only, and is not part of ajax-based solutions.
</ul>
<p>8) Code size should not exceed 200K (minified and gzip&#8217;d); the smaller the better</p>
<ul>
<li>File size: 68K minified / 20K gzip&#8217;d.  This is outstanding !!
<li>With addl plugins (FixedColumns, Scroller, etc.), +  20K minified / 6K gzip&#8217;d
</ul>
<p>9) We will only select a mature, well supported Table widget. We will not make our own.</p>
<ul>
<li>DataTables is currently in version 1.9.2
<li>and has been developed now for 4 years, since 2008
<li>has over 10,000 threads in its on-line forums
<li>backed by a suite of 2800 unit tests
<li>provides over 130 pre-built examples
</ul>
<p>10) Theming Support :</p>
<ul>
<li>DataTables supports JQuery ThemeRoller classes
<li>DataTables allows users to specify what class names to associate with HTML elements
<li>DataTables can render its add-on widgets (nav bar, search field, etc.) in HTML-provided div&#8217;s
</ul>
<p>11) Table must by stylable to may our particular look and feel</p>
<ul>
<li>With DataTables liberal handling of class names (user-definable globals hold class names), I believe it can be styled to match our needs
<li>DataTables provides a Column Renderer which is passed the backing row Object and the property value &#8230;giving the renderer the opportunity to display addl fields in each cell
<li>DataTables permits row expansion showing more details about a row Object
</ul>
<p>12) Row selection (single select for now; multi-select for future)</p>
<ul>
<li>DataTables supports single selection via row-selection or checkboxes
<li>DataTables supports multi-select across page boundries (sending selections to server)
</ul>
<p>13) Links / Actions &#8211; in-row actions for now; likely top-of list actions for future</p>
<ul>
<li>DataTables supports any buttons you need to place in a row
<li>If requested, DataTables will add unique IDs to each row in a paged table
<li>DataTables also supports custom events which code can bind to
</ul>
<p>14) Editing: no in-cell editing for now</p>
<ul>
<li>With its Editor plugin, DataTables does support in-cell editing if desired
</ul>
<p>15) Alternate Views: no &#8220;View As&#8230;&#8221; alternate views for now</p>
<ul>
<li>DataTables does not directly support alternate views for its tables
</ul>
<p>16) No conclusion on table width handling. However, most people would like to see columns shrink until it&#8217;s ridiculous, then hide low-priority columns altogether</p>
<ul>
<li>DataTables supports a dynamic width for its tables
<li>Columns resize when the table resizes
<li>Data within the cells re-wraps unto addl lines as needed (IOW, <strong>row height is not fixed</strong> when paginating via the navigation bar)
<li>Uncertain if DataTables could auto-show/hide low priority columns based on table width
</ul>
<p>17) The table needs to support a distribution-friendly license</p>
<ul>
<li>DataTables is dual licensed under the GPL v2 license or a BSD (3-point) license
<li>I&#8217;m no lawyer, but I suspect the BSD license is sufficient
</ul>
<p>Notable Params &#8212; 125 params exist!!</p>
<pre>
sServerMethod    - HTTP method to use GET | POST
bAutoWidth       - enable auto col width calculation; disable if col widths are in aoColumns
bProcessing      - show a "processing request" message
bPaginate        - enable pagination
sPaginationType  - style of pagination buttons/links; two_buttons
bLengthChange    - show the page size combo; requires bPaginate
aLengthMenu      - [[values], [display]]: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]]
iDisplayLength   - size of a page
bFilter          - show the search box; to remove box but keep filter ability, use sDom
bRegEx           - interpret search string as a regEx expression
bSmart           - use DataTable's smart filtering methods to match words at any point in the data
bJQueryUI        - enable JQuery UI ThemeRoller support; affects visibility of prev/next links
bInfo            - Show status bar details about the current table data; 1 to 10 of 100 (# filtered)
bScrollInfinite  - Pagination by using only the scroll bar
iScrollLoadGap   - Amount of scrolling left to go before pre-fetching the next page
bScrollCollapse  - Controls if the table's viewport should be shrunk on the last page
sScrollX         - Specify horizontal scrolling; blank = disabled
sScrollY         - Specify vertical scrolling
bSort            - Enable sorting; individual cols can be disabled /w bSortable option on each col "bSortClasses"
bStateSave       - Enable state saving; uses cookies
bDeferRender     - Only draw those rows that are visible; draw addl as needed
bServerSide      - filter, sort, page on server; must be used with sAjaxSource
sAjaxSource      - URL: /rest/service/endpoint
aoColumns        - Define column model
fnServerParams   - Define any addl data to send with page request
sDom             - Tell DataTables in what div's to render it search, msgs, &#038; nav bar widgets
fnRender         - Rendering function used to draw cell contents
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=70</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What&#8217;s Good Enough?</title>
		<link>http://www.peterclemons.org/blog/?p=82</link>
		<comments>http://www.peterclemons.org/blog/?p=82#comments</comments>
		<pubDate>Sun, 01 Jul 2012 06:54:51 +0000</pubDate>
		<dc:creator><![CDATA[peter]]></dc:creator>
				<category><![CDATA[JavaScript Table Widgets]]></category>

		<guid isPermaLink="false">http://www.peterclemons.org/blog/?p=82</guid>
		<description><![CDATA[Based on survey results and subsequent discussions, here&#8217;s what we decided for a table widget: Performance is #1 Device requirements: performance and functionality will be determined by low-powered, ICS-based tablets, not older Honeycomb devices, not smart phones Table paging and &#8230; <a href="http://www.peterclemons.org/blog/?p=82">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Based on survey results and subsequent discussions, here&#8217;s what we decided for a table widget:</p>
<ol>
<li>Performance is #1
<li>Device requirements: performance and functionality will be determined by low-powered, ICS-based tablets, not older Honeycomb devices, not smart phones
<li>Table paging and navigation will be performed by next, prev, first, last, and #&#8217;s links
<li>The table will load 1 &#8220;page&#8221; of data at a time, if the rows don&#8217;t &#8220;fit&#8221; the vertical table size, users may scroll to see the rest of the page
<li>The table will not cache previous requests (to protect mobile devices; and if #1 is met, no need)
<li>All paging, filtering, sorting will be performed by the back-end; none in the client
<li>We will filter on only string data originating from the server for now.  Filters on dates, UI-localized strings, enums, etc. will not function in the first release
<li>Code size should not exceed 200K (minified and gzip&#8217;d); the smaller the better
<li>We will only select a mature, well supported Table widget. We will not make our own.
<li>We would prefer a Theming model based on<br />
       &nbsp;&nbsp;- ThemeRoller for JQuery-Mobile<br />
       &nbsp;&nbsp;- if not ThemeRoller for JQuery<br />
       &nbsp;&nbsp;- if not code-specified style names<br />
       &nbsp;&nbsp;- anything goes</p>
<li>Table must by stylable as in our mockups
<li>Single select for now; likely multi-select for future
<li>In-row links / actions for now; likely top-of list actions for future
<li>No in-cell editing for now
<li>No &#8220;View As&#8230;&#8221; alternate views for now
<li>No conclusion on table width handling.  However, most people would like to see columns shrink until it&#8217;s ridiculous, then hide low-priority columns altogether
<li>The table needs to support a distribution-friendly license
</ol>
<p><strong>Next Steps</strong> &#8211; evaluate table controls along these criteria<br />
- Those table controls that are still in the running after this analysis will be wired up against live / real data<br />
- However, the data will be cached in the server in order to eliminate the server portion of the performance analysis (we want to see how well the grids perform &#8230;not how long the server takes to fulfill a request)<br />
- We have narrowed the list to DataTables, jqGrid, and SlickGrid &#8230;and a quick peek at JQuery</p>
<p>- DataTables</p>
<ul>
<li>Home: <a href="http://datatables.net/">http://datatables.net/</a>
<li>Examples: <a href="http://www.datatables.net/examples/">http://www.datatables.net/examples/</a>
<li>Tests: <a href="https://github.com/DataTables/DataTables/tree/master/media/unit_testing">https://github.com/DataTables/DataTables/tree/master/media/unit_testing</a>
<li>License: BSD or GPLv2
<li>Most notable features: 20K gzip&#8217;d, plugins for addl features; 2800 unit tests; 130 examples
</ul>
<p>- SlickGrid</p>
<ul>
<li>Home: <a href="https://github.com/mleibman/SlickGrid/wiki">https://github.com/mleibman/SlickGrid/wiki</a>
<li>Examples: <a href="https://github.com/mleibman/SlickGrid/wiki/Examples">https://github.com/mleibman/SlickGrid/wiki/Examples</a>
<li>Used By: <a href="https://github.com/mleibman/SlickGrid/wiki/Used-by">https://github.com/mleibman/SlickGrid/wiki/Used-by</a>
<li>License: MIT
<li>Current version: 2.0.1, actively developed
<li>Most notable features: speed, virtual rendering
</ul>
<p>- jqGrid</p>
<ul>
<li>Current version: 4.4.0, actively developed
<li>Home: <a href="http://www.trirand.com/blog/">http://www.trirand.com/blog/</a>
<li>Examples: <a href="http://www.trirand.com/blog/jqgrid/jqgrid.html">http://www.trirand.com/blog/jqgrid/jqgrid.html</a>
<li>Demos: <a href="http://www.trirand.com/blog/jqgrid/downloads/jqgrid_demo38.zip">http://www.trirand.com/blog/jqgrid/downloads/jqgrid_demo38.zip</a>
<li>License: MIT or GPL
<li>Most notable features: ?
</ul>
<p>- JQuery UI Grid &#8211; not really a candidate since it appears this component is currently on hold</p>
<ul>
<li>Home: <a href="http://wiki.jqueryui.com/w/page/34246941/Grid#jQueryUIGridProject">http://wiki.jqueryui.com/w/page/34246941/Grid#jQueryUIGridProject</a>
<li>Due to its development timeframe, it is unlikely we will use this widget.
<li>But since it&#8217;s part of the JQuery project, it would be good to learn more about it.
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.peterclemons.org/blog/?feed=rss2&#038;p=82</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
