Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Tuesday, June 26, 2012

Some useful jQuery plugins

Beside previously described jQuery Datatables and accompanying plugins which help you deal with all sort of basic table functionality and advanced transformations (from basic searching, sorting, filtering, pagination to row grouping, inline editing etc.), you can find jQuery plugins for many other needs. Some of them make our life easier by adding core functionality and allowing us to avoid boilerplate code. Others take care of good appearance and add interactivity. Here are few plugins from both sides which come in handy. Hope you'll find them just as useful and interesting.

Quicksand - Animated sorting and filtering:
http://razorjack.net/quicksand/

Nivo Slider - Nice looking slider with fancy transition effects:
http://nivo.dev7studios.com/
Uniform - unified form look and feel:

http://uniformjs.com/

Several jQuery plugins for facing Google Maps:

http://speckyboy.com/2010/02/03/10-jquery-plugins-for-easier-google-map-installation/
Few AJAX jQuery file uploaders:

http://creativefan.com/10-ajax-jquery-file-uploaders/

Collection of Forms plugins:

http://www.tripwiremagazine.com/2011/06/jquery-forms-plugins.html 


Tuesday, May 15, 2012

Fancy tables in few steps - jQuery DataTables

Dealing with tables... You probably did it thousands of times... Sorting, filtering, pagination...
What do you use? Is there something nice and easy to spare our time and effort?
Here's one proposition, and if you have something better please let me know.

jQuery DataTables! Let's see... First you need to download couple of things:

1) DataTables jQuery plugin - obtaining functionality and basic look and feel
2) jQuery UI - to make it smooth

Instead of a plain table you can have something like this by adding only a few lines of code.
Source code can be downloaded from here.



1) Include needed js and css files (you can find an example below) in the header section.
2) Add the following piece of code:

$(document).ready(function() {
    $('table#people').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers"
    });
} );

This tells browser that after document is fully loaded it should take table with "people" id and execute dataTable function, and thereby generate fancy table you saw above. Arguments bJQueryUI and sPaginationType tell that support for ThemeRoller should be enabled and that pagination should be presented by full numbers instead of two arrows ("two_button" is a default value), respectively. Beside two given options there are others which you may find just as useful.

IMPORTANT: You need to use VALID table format if you want it to be properly rendered. If <thead>, <th>, and <tbody> tags are missing you'll get a weird result.

Example:


   
<html>
 <head>   
  <title>DataTables Demo</title>
  <style title="currentStyle" type="text/css">
   @import "media/css/demo_page.css";
   @import "media/css/demo_table_jui.css";
   @import "media/css/redmond/jquery-ui.custom.css";  
  </style>
  <script src="media/js/jquery.js" type="text/javascript"></script>
  <script src="media/js/jquery.dataTables.min.js" type="text/javascript"></script>
  <script src="media/js/jquery-ui.lightness.min.js" type="text/javascript"></script>
  <script charset="utf-8" type="text/javascript">
   $(document).ready( function () {
              $('table#people').dataTable({
       "bJQueryUI": true,
       "sPaginationType": "full_numbers"     
     } );
   } );
  </script>
 </head>
 <body>
  <table class="display" id="people">
   <thead>
  <tr>
     <th>First Name</th>
     <th>Last Name</th>
     <th>Field</th>
    </tr>
   </thead>
  <tbody>
<tr><td>Walt</td><td>Disney</td><td>Art</td></tr>
<tr><td>Isac</td><td>Newton</td><td>Science</td></tr>
<tr><td>Charles</td><td>Dickens</td><td>Literature</td></tr>
<tr><td>Michael</td><td>Jordan</td><td>Sport</td></tr>
<tr><td>Thomas</td><td>Edison</td><td>Engineering</td></tr>
<tr><td>Niel</td><td>Armstrong</td><td>Art</td></tr>
<tr><td>Leonardo</td><td>Da Vinci</td><td>Art</td></tr>
<tr><td>Roger</td><td>Federer</td><td>Sport</td></tr>
<tr><td>Vincent</td><td>Van Gogh</td><td>Art</td></tr>
<tr><td>Louis</td><td>Pasteur</td><td>Science</td></tr>
<tr><td>Mark</td><td>Twain</td><td>Literature</td></tr>
<tr><td>Jesse</td><td>Owens</td><td>Sport</td></tr>
</tbody>
  </table>
</body>
</html>
Note: class "display" is needed for adequate styling.