Skip to content

Commit

Permalink
merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
bmac committed Sep 7, 2012
2 parents ba409a2 + 898357f commit 89b2b85
Show file tree
Hide file tree
Showing 122 changed files with 4,082 additions and 1,796 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ docs
cdn
media/js/jquery.dataTables.min.js
.DS_Store
Plugins
20 changes: 10 additions & 10 deletions examples/ajax/deep.html
Expand Up @@ -17,11 +17,11 @@
"bProcessing": true,
"sAjaxSource": "sources/deep.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform.inner" },
{ "mDataProp": "platform.details.0" },
{ "mDataProp": "platform.details.1" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform.inner" },
{ "mData": "platform.details.0" },
{ "mData": "platform.details.1" }
]
} );
} );
Expand Down Expand Up @@ -71,11 +71,11 @@ <h1>Initialisation code</h1>
"bProcessing": true,
"sAjaxSource": "sources/deep.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform.inner" },
{ "mDataProp": "platform.details.0" },
{ "mDataProp": "platform.details.1" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform.inner" },
{ "mData": "platform.details.0" },
{ "mData": "platform.details.1" }
]
} );
} );</pre>
Expand Down
6 changes: 3 additions & 3 deletions examples/ajax/null_data_source.html
Expand Up @@ -22,7 +22,7 @@
null,
null,
null,
{ "mDataProp": null }
{ "mData": null }
]
} );
} );
Expand All @@ -35,7 +35,7 @@
</div>

<h1>Preamble</h1>
<p>In some tables it can be useful to not need to specify any data source for a column, as it's content is automatically generated (for example using fnRender). This is fairly common with add, edit and delete columns for a CRUD interface. You can now use the <b>mDataProp</b> set to <i>null</i> to specify that the column has no data source. DataTables will render this column as empty.</p>
<p>In some tables it can be useful to not need to specify any data source for a column, as it's content is automatically generated (for example using fnRender). This is fairly common with add, edit and delete columns for a CRUD interface. You can now use the <b>mData</b> set to <i>null</i> to specify that the column has no data source. DataTables will render this column as empty.</p>

<h1>Live example</h1>
<div id="dynamic">
Expand Down Expand Up @@ -67,7 +67,7 @@ <h1>Initialisation code</h1>
null,
null,
null,
{ "mDataProp": null }
{ "mData": null }
]
} );
} );</pre>
Expand Down
20 changes: 10 additions & 10 deletions examples/ajax/objects.html
Expand Up @@ -17,11 +17,11 @@
"bProcessing": true,
"sAjaxSource": "sources/objects.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "version" },
{ "mDataProp": "grade" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform" },
{ "mData": "version" },
{ "mData": "grade" }
]
} );
} );
Expand Down Expand Up @@ -71,11 +71,11 @@ <h1>Initialisation code</h1>
"bProcessing": true,
"sAjaxSource": "sources/objects.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "version" },
{ "mDataProp": "grade" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform" },
{ "mData": "version" },
{ "mData": "grade" }
]
} );
} );</pre>
Expand Down
20 changes: 10 additions & 10 deletions examples/ajax/objects_subarrays.html
Expand Up @@ -17,11 +17,11 @@
"bProcessing": true,
"sAjaxSource": "sources/objects_subarrays.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "details.0" },
{ "mDataProp": "details.1" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform" },
{ "mData": "details.0" },
{ "mData": "details.1" }
]
} );
} );
Expand Down Expand Up @@ -71,11 +71,11 @@ <h1>Initialisation code</h1>
"bProcessing": true,
"sAjaxSource": "sources/objects_subarrays.txt",
"aoColumns": [
{ "mDataProp": "engine" },
{ "mDataProp": "browser" },
{ "mDataProp": "platform" },
{ "mDataProp": "details.0" },
{ "mDataProp": "details.1" }
{ "mData": "engine" },
{ "mData": "browser" },
{ "mData": "platform" },
{ "mData": "details.0" },
{ "mData": "details.1" }
]
} );
} );</pre>
Expand Down
16 changes: 8 additions & 8 deletions examples/api/counter_column.html
Expand Up @@ -15,13 +15,14 @@
$(document).ready(function() {
$('#example').dataTable( {
"fnDrawCallback": function ( oSettings ) {
var that = this;

/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
{
$('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 );
}
this.$('td:first-child', {"filter":"applied"}).each( function (i) {
that.fnUpdate( i+1, this.parentNode, 0, false, false );
} );
}
},
"aoColumnDefs": [
Expand Down Expand Up @@ -539,10 +540,9 @@ <h1>Initialisation code</h1>
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i&lt;iLen ; i++ )
{
$('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 );
}
this.$('td:first-child', {"filter":"applied"}).each( function (i) {
that.fnUpdate( i+1, this.parentNode, 0, false, false );
} );
}
},
"aoColumnDefs": [
Expand Down
1 change: 1 addition & 0 deletions examples/api/editable.html
Expand Up @@ -45,6 +45,7 @@ <h1>Preamble</h1>
<p>Using DataTables in-combination with the excellent <a href="http://www.appelsiini.net/projects/jeditable">jEditable</a> plugin for jQuery allows you to produce a table which can have individual cells edited. The table can then be updated such that filtering, sorting etc. will all work as expected. This is showing in the demo below.</p>
<p>The example shows how a table element can be edited (you could limit to a particular column if you wish using the selector), posted to the server (for saving in a database or whatever) and then placed back into the DataTable. The server's processing in this example simply appends the string '(server updated)' to indicate that something has happened on the server.</p>
<p>Note also that this example makes use of the information in the 'ID' attribute of the TR element. This is useful in order to tell the server what row is being updated - this can readily be expended to include column information as required. Further to this, it is worth noting that to use this type of example with DataTables' server-side processing option, you must use <a href="http://datatables.net/usage/callbacks#fnDrawCallback">fnDrawCallback</a> to apply the event listeners on each draw.</p>
<p>Finally, if you are interested in a full <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> implementation for DataTables, check out the <a href="http://editor.datatables.net">Editor plug-in for DataTables</a>, which provides a flexible and easy to use create, edit and delete environment for DataTables controlled tables with full server interaction.</p>

<h1>Live example</h1>
<div id="demo">
Expand Down
8 changes: 4 additions & 4 deletions examples/api/multi_filter_select.html
Expand Up @@ -28,13 +28,13 @@
// check that we have a column id
if ( typeof iColumn == "undefined" ) return new Array();

// by default we only wany unique data
// by default we only want unique data
if ( typeof bUnique == "undefined" ) bUnique = true;

// by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) bFiltered = true;

// by default we do not wany to include empty values
// by default we do not want to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;

// list of rows which we're going to loop through
Expand Down Expand Up @@ -554,13 +554,13 @@ <h1>Initialisation code</h1>
// check that we have a column id
if ( typeof iColumn == "undefined" ) return new Array();

// by default we only wany unique data
// by default we only want unique data
if ( typeof bUnique == "undefined" ) bUnique = true;

// by default we do want to only look at filtered data
if ( typeof bFiltered == "undefined" ) bFiltered = true;

// by default we do not wany to include empty values
// by default we do not want to include empty values
if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;

// list of rows which we're going to loop through
Expand Down
8 changes: 6 additions & 2 deletions examples/api/select_single_row.html
Expand Up @@ -29,7 +29,9 @@
/* Add a click handler for the delete row */
$('#delete').click( function() {
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
if ( anSelected.length !== 0 ) {
oTable.fnDeleteRow( anSelected[0] );
}
} );

/* Init the table */
Expand Down Expand Up @@ -503,7 +505,9 @@ <h1>Initialisation code</h1>
/* Add a click handler for the delete row */
$('#delete').click( function() {
var anSelected = fnGetSelected( oTable );
oTable.fnDeleteRow( anSelected[0] );
if ( anSelected.length !== 0 ) {
oTable.fnDeleteRow( anSelected[0] );
}
} );

/* Init the table */
Expand Down
12 changes: 6 additions & 6 deletions examples/api/tabs_and_scrolling.html
Expand Up @@ -18,9 +18,9 @@
$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
if ( oTable.length > 0 ) {
oTable.fnAdjustColumnSizing();
var table = $.fn.dataTable.fnTables(true);
if ( table.length > 0 ) {
$(table).dataTable().fnAdjustColumnSizing();
}
}
} );
Expand Down Expand Up @@ -300,9 +300,9 @@ <h1>Initialisation code</h1>
<pre class="brush: js;">$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var oTable = $('div.dataTables_scrollBody&gt;table.display', ui.panel).dataTable();
if ( oTable.length &gt; 0 ) {
oTable.fnAdjustColumnSizing();
var table = $.fn.dataTable.fnTables(true);
if ( table.length &gt; 0 ) {
$(table).dataTable().fnAdjustColumnSizing();
}
}
} );
Expand Down
6 changes: 4 additions & 2 deletions examples/basic_init/scroll_y.html
Expand Up @@ -16,7 +16,8 @@
$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"bPaginate": false
"bPaginate": false,
"bScrollCollapse": true
} );
} );
</script>
Expand Down Expand Up @@ -465,7 +466,8 @@ <h1>Initialisation code</h1>
<pre class="brush: js;">$(document).ready(function() {
$('#example').dataTable( {
"sScrollY": "200px",
"bPaginate": false
"bPaginate": false,
"bScrollCollapse": true
} );
} );</pre>
<style type="text/css">
Expand Down
28 changes: 13 additions & 15 deletions examples/data_sources/server_side.html
Expand Up @@ -82,12 +82,6 @@ <h1>Server response</h1>

<h1>Server side (PHP) code</h1>
<pre>&lt;?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
Expand All @@ -109,6 +103,9 @@ <h1>Server side (PHP) code</h1>
$gaSql['db'] = "";
$gaSql['server'] = "localhost";

/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
Expand Down Expand Up @@ -139,15 +136,16 @@ <h1>Server side (PHP) code</h1>
/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i&lt;intval( $_GET['iSortingCols'] ) ; $i++ )
{
if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
{
$sOrder .= $aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."
".mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", ";
$sOrder .= "`".$aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."` ".
mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", ";
}
}

Expand All @@ -166,12 +164,12 @@ <h1>Server side (PHP) code</h1>
* on very large tables, and MySQL's regex functionality is very limited
*/
$sWhere = "";
if ( $_GET['sSearch'] != "" )
if ( isset($_GET['sSearch']) &amp;&amp; $_GET['sSearch'] != "" )
{
$sWhere = "WHERE (";
for ( $i=0 ; $i&lt;count($aColumns) ; $i++ )
{
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
$sWhere .= "`".$aColumns[$i]."` LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ')';
Expand All @@ -180,7 +178,7 @@ <h1>Server side (PHP) code</h1>
/* Individual column filtering */
for ( $i=0 ; $i&lt;count($aColumns) ; $i++ )
{
if ( $_GET['bSearchable_'.$i] == "true" &amp;&amp; $_GET['sSearch_'.$i] != '' )
if ( isset($_GET['bSearchable_'.$i]) &amp;&amp; $_GET['bSearchable_'.$i] == "true" &amp;&amp; $_GET['sSearch_'.$i] != '' )
{
if ( $sWhere == "" )
{
Expand All @@ -190,7 +188,7 @@ <h1>Server side (PHP) code</h1>
{
$sWhere .= " AND ";
}
$sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
$sWhere .= "`".$aColumns[$i]."` LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
}
}

Expand All @@ -200,12 +198,12 @@ <h1>Server side (PHP) code</h1>
* Get data to display
*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
SELECT SQL_CALC_FOUND_ROWS `".str_replace(" , ", " ", implode("`, `", $aColumns))."`
FROM $sTable
$sWhere
$sOrder
$sLimit
";
";
$rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());

/* Data set length after filtering */
Expand All @@ -218,7 +216,7 @@ <h1>Server side (PHP) code</h1>

/* Total data set length */
$sQuery = "
SELECT COUNT(".$sIndexColumn.")
SELECT COUNT(`".$sIndexColumn."`)
FROM $sTable
";
$rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
Expand Down

0 comments on commit 89b2b85

Please sign in to comment.