Skip to content

Commit

Permalink
New: The primary public interface for DataTables' initialisation opti…
Browse files Browse the repository at this point in the history
…ons is now camel case parameters rather than the Hungarian notation that was used before. There are a number of reasons for doing this, the primary one being that the Hungarian notation used by DataTables is actively stopping people from using the library due to their aversion to using Hungarian notation. Without doubt the Hungarian notation used was a mistake (the reason it was used was that when DataTables was originally written, the company I worked for at the time required the use of Hungarian notation, and thus I was trained in it...).

Backwards compatibility issues: The main goal here (other than to use camel-case notation!) is to preserve backwards compatibility. Unfortunately this isn't 100% possible:
	- DataTable.defaults.columns has been renamed to be DataTable.defaults.column
		- Otherwise it conflicts with aoColumns in the defaults.

Without doubt this is going to be a long process - for example the unit tests and examples need to be completely updated for this change. The JSDoc comments have been updated, so the site should take care of itself for the most part, when released.

In terms of implementation, it is important to note that I have not broken backwards compatibility here - the way it is does is that the current defaults are retained, and a camel-case to Hungarian mapping is automatically generated and then applied to the objects given by the end user. This adds around 0.5K to the size of DataTables, but writing the mapping manually would require at least 3K, and changing DataTables wholesale to camel-case would utterly break backwards compatibility. This is the least 'evil' way to accomplish this. It is important to note that this is a step along the roadmap for DataTables - come v2 Hungarian notation will likely be dropped completely.

One important note to make about this mapping is that if you use camel-case DataTables will copy the value from the camel-case properties to their Hungarian counterparts, so you will end up with additional properties on your source object. As I say, this appears to be to be the least 'evil' option, although still not perfect itself. The challenges of working with legacy software and installs...!
  • Loading branch information
Allan Jardine committed Oct 7, 2012
1 parent 65cde4c commit a0455fa
Show file tree
Hide file tree
Showing 19 changed files with 1,736 additions and 1,155 deletions.
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DataTables",
"version": "1.9.4",
"version": "1.10.0.dev",
"main": [
"./media/js/jquery.dataTables.js",
"./media/css/jquery.dataTables.css",
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced_init/defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$.extend( $.fn.dataTable.defaults, {
"bFilter": false,
"bSort": false
"filter": false,
"sort": false
} );

$('#example').dataTable();
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced_init/language_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sUrl": "../examples_support/de_DE.txt"
"language": {
"url": "../examples_support/de_DE.txt"
}
} );
} );
Expand Down
6 changes: 3 additions & 3 deletions examples/basic_init/hidden_columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"aoColumnDefs": [
{ "bSearchable": false, "bVisible": false, "aTargets": [ 2 ] },
{ "bVisible": false, "aTargets": [ 3 ] }
"columnDefs": [
{ "searchable": false, "visible": false, "targets": [ 2 ] },
{ "visible": false, "targets": [ 3 ] }
] } );
} );
</script>
Expand Down
14 changes: 7 additions & 7 deletions examples/basic_init/language.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
"language": {
"lengthMenu": "Display _MENU_ records per page",
"zeroRecords": "Nothing found - sorry",
"info": "Showing _START_ to _END_ of _TOTAL_ records",
"infoEmpty": "Showing 0 to 0 of 0 records",
"infoFiltered": "(filtered from _MAX_ total records)"
}
} );
} );
Expand Down Expand Up @@ -463,7 +463,7 @@ <h1>Live example</h1>

<h1>Initialisation code</h1>
<pre class="brush: js;">$(document).ready(function() {
$('#example').dataTable( {
$('#example').dataTable( {
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
Expand Down
4 changes: 2 additions & 2 deletions examples/basic_init/themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
"jQueryUI": true,
"paginationType": "full_numbers"
});
} );
</script>
Expand Down
4 changes: 3 additions & 1 deletion examples/basic_init/zero_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#example').dataTable();
$('#example').dataTable( {
bSort: false
} );
} );
</script>
</head>
Expand Down
28 changes: 14 additions & 14 deletions examples/examples_support/de_DE.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"sProcessing": "Bitte warten...",
"sLengthMenu": "_MENU_ Einträge anzeigen",
"sZeroRecords": "Keine Einträge vorhanden.",
"sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen",
"sInfoEmpty": "0 bis 0 von 0 Einträgen",
"sInfoFiltered": "(gefiltert von _MAX_ Einträgen)",
"sInfoPostFix": "",
"sSearch": "Suchen",
"sUrl": "",
"oPaginate": {
"sFirst": "Erster",
"sPrevious": "Zurück",
"sNext": "Nächster",
"sLast": "Letzter"
"processing": "Bitte warten...",
"lengthMenu": "_MENU_ Einträge anzeigen",
"zeroRecords": "Keine Einträge vorhanden.",
"info": "_START_ bis _END_ von _TOTAL_ Einträgen",
"infoEmpty": "0 bis 0 von 0 Einträgen",
"infoFiltered": "(gefiltert von _MAX_ Einträgen)",
"infoPostFix": "",
"search": "Suchen",
"url": "",
"paginate": {
"first": "Erster",
"previous": "Zurück",
"next": "Nächster",
"last": "Letzter"
}
}
Loading

0 comments on commit a0455fa

Please sign in to comment.