diff --git a/examples_src/basic_init/alt_pagination.xml b/examples_src/basic_init/alt_pagination.xml new file mode 100644 index 00000000..cf8a66c8 --- /dev/null +++ b/examples_src/basic_init/alt_pagination.xml @@ -0,0 +1,23 @@ + + + + + + + +Alternative pagination + + + +

The page controls which are used by default in DataTables (forward and backward buttons only) are great for most situations, but there are cases where you may wish to customise the controls presented to the end user. This is made simple by DataTables through its extensible pagination mechanism. There are two types of pagination controls built into DataTables: two_button (default) and full_numbers. To switch between these two types, use the paginationType initialisation parameter. You can add additional types of pagination control by extending the $.fn.dataTableExt.oPagination object.

+ +

The example below shows the full_numbers type of pagination, where 'first', 'previous', 'next' and 'last' buttons are presented, as well as the five pages around the current page.

+
+ +
diff --git a/examples_src/basic_init/complex_header.xml b/examples_src/basic_init/complex_header.xml new file mode 100644 index 00000000..4262987d --- /dev/null +++ b/examples_src/basic_init/complex_header.xml @@ -0,0 +1,19 @@ + + + + + + + +Complex headers (row and colspans) + + + +When using tables to display data, you will often wish to display column information in groups. DataTables fully supports colspan and rowspans in the header, assigning the required sorting listeners to the TH element suitable for that column. Each column must have one TH cell (and only one) which is unique to it for the listeners to be added. The example shown below has the core browser information grouped together. + + + diff --git a/examples_src/basic_init/dom.xml b/examples_src/basic_init/dom.xml new file mode 100644 index 00000000..33d02604 --- /dev/null +++ b/examples_src/basic_init/dom.xml @@ -0,0 +1,33 @@ + + + + + + + +DOM positioning +rt<"bottom"flp><"clear">' + } ); +} ); +]]> + + +

When customising DataTables for your own usage, you might find that the default position of the feature elements (filter input etc) is not quite to your liking. To address this issue DataTables takes inspiration from the CSS 3 Advanced Layout Module and provides the dom initialisation parameter which can be set to indicate where you which particular features to appear in the DOM. You can also specify div wrapping containers (with classes) to provide complete layout flexibility. The syntax available is:

+
    +
  • l - Length changing
  • +
  • f - Filtering input
  • +
  • t - The table!
  • +
  • i - Information
  • +
  • p - Pagination
  • +
  • r - pRocessing
  • +
  • < and > - div elements
  • +
  • <"class" and > - div with a class
  • +
  • Examples: <"wrapper"flipt>, <lf<t>ip>
  • +
+

In the example below I've moved the table information to the top of the table, and all the interaction elements to the bottom, each wrapper in a container div.

+
+ +
diff --git a/examples_src/basic_init/filter_only.xml b/examples_src/basic_init/filter_only.xml new file mode 100644 index 00000000..605ed6a3 --- /dev/null +++ b/examples_src/basic_init/filter_only.xml @@ -0,0 +1,26 @@ + + + + + + + +Feature enable / disable + + + +Disabling features that you don't wish to use for a particular table is easily done by setting a variable in the initialisation object. In the following example only the filter feature is left enabled (although I've explicitly declared it as enabled). + + + diff --git a/examples_src/basic_init/flexible_width.xml b/examples_src/basic_init/flexible_width.xml new file mode 100644 index 00000000..c2f34386 --- /dev/null +++ b/examples_src/basic_init/flexible_width.xml @@ -0,0 +1,21 @@ + + + + + + + +Flexible table width + + + +

Often you may want to have your table resize dynamically with the page. Typically this is done by assigning width:100% in your CSS, but this presents a problem for Javascript since it can be very hard to get that relative size, rather than the absolute pixels. As such, if you apply the width attribute to the HTML table tag, this will be used as the width for the table (overruling any CSS styles).

+ +

This example shows a table width width="100%" and the container is also flexible width, so as the window is resized, the table will also resize dynamically.

+
+ +
diff --git a/examples_src/basic_init/hidden_columns.xml b/examples_src/basic_init/hidden_columns.xml new file mode 100644 index 00000000..51a9ead8 --- /dev/null +++ b/examples_src/basic_init/hidden_columns.xml @@ -0,0 +1,24 @@ + + + + + + + +Hidden columns + + + +There are times when you might find it useful to display only a sub-set of the information that was available in the original table. For example you might want to reduce the amount of data shown on screen to make it clearer for the user. This hidden data can still be filtered upon allowing the user access to that data (for example 'tag' information for a row entry), or this can be disabled. In the table below both the platform and engine version columns have been hidden, the former is searchable, the latter is not. + + + diff --git a/examples_src/basic_init/index.xml b/examples_src/basic_init/index.xml new file mode 100644 index 00000000..2cc6d041 --- /dev/null +++ b/examples_src/basic_init/index.xml @@ -0,0 +1,19 @@ + + + + + + + +Zero configuration + + + + DataTables has most features enabled by default, so all you need to do to use it with one of your own tables is to call the construction function (as shown below). + + + diff --git a/examples_src/basic_init/language.xml b/examples_src/basic_init/language.xml new file mode 100644 index 00000000..0d895750 --- /dev/null +++ b/examples_src/basic_init/language.xml @@ -0,0 +1,27 @@ + + + + + + + +Language options + + + +Changing the language information displayed by DataTables is as simple as passing in a language object to the dataTable constructor. The example above shows a different set of English language definitions to be used, rather than the defaults. + + + diff --git a/examples_src/basic_init/multi_col_sort.xml b/examples_src/basic_init/multi_col_sort.xml new file mode 100644 index 00000000..1a4231dc --- /dev/null +++ b/examples_src/basic_init/multi_col_sort.xml @@ -0,0 +1,43 @@ + + + + + + + +Multi-column and custom sort + b) ? 1 : 0)); + }, + + "string-case-desc": function(a,b) { + return ((a < b) ? 1 : ((a > b) ? -1 : 0)); + } +} ); + +$(document).ready(function() { + /* Build the DataTable with third column using our custom sort function */ + $('#example').dataTable( { + "sorting": [ [0,'asc'], [1,'asc'] ], + "columnDefs": [ { + "targets": [ 2 ], + "type": 'string-case' + } ] + } ); +} ); +]]> + + +

As you would expect with a desktop application, DataTables allows you to sort by multiple columns at the same time. This multiple sorting mechanism is always active if the sort initialiser is true (it is by default) and the end user can activate it by 'shift' clicking on the column they want to add to the sort. You can also pass in an array of information using the sorting initialiser, as I have done in the example below there the first column is sorted as the primary column and the second one then used if the elements in the first column match. As many columns as you wish can be added to the sort.

+ +

DataTables also provides a method to add your own sorting functions, to extend those built into DataTables. This can be very useful if you wish to sort on data formats such as currency and non-Javascript standard date formats (this natural sort algorithm is a popular option). This is achieved by extending the jQuery.fn.dataTableExt object with ascending and descending sort functions. In the example below I've added case sensitive sorting functions.

+
+ +
diff --git a/examples_src/basic_init/multiple_tables.xml b/examples_src/basic_init/multiple_tables.xml new file mode 100644 index 00000000..898a8c2b --- /dev/null +++ b/examples_src/basic_init/multiple_tables.xml @@ -0,0 +1,19 @@ + + + + + + + +Multiple tables + + + +Using standard jQuery selector syntax with DataTables it is trivial to initialise multiple tables with a single line of Javascript, as shown below. All tables are completely independent, but share the parameters passed thought the initialiser object (for example if you specific the Spanish language file, all tables will be shown in Spanish). + + + diff --git a/examples_src/basic_init/scroll_x.xml b/examples_src/basic_init/scroll_x.xml new file mode 100644 index 00000000..ec1396e1 --- /dev/null +++ b/examples_src/basic_init/scroll_x.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + +

This DataTables horizontal scrolling example shows horizontal scrolling on a DataTable, which is very useful for when you have a wide table, with a large number of columns to display, but want to constrain it to a limited horizontal display area. To enable x-scrolling simply set the scrollX parameter to be whatever you want the container wrapper's width to be (any CSS measurement is acceptable, or just a number which is treated as pixels). Note also that sScrollXInner is used here to force the table to be wider than is strictly needed. You may or may not want to include this parameter depending on your application.

+

Also shown in this example is the use of a 'collapsing scroll table' by using scrollCollapse. When this parameter is set to true, the table size will 'collapse' down to match the number of rows, if the table height is smaller than the scrollable area.

+
+ +
diff --git a/examples_src/basic_init/scroll_xy.xml b/examples_src/basic_init/scroll_xy.xml new file mode 100644 index 00000000..1189c410 --- /dev/null +++ b/examples_src/basic_init/scroll_xy.xml @@ -0,0 +1,23 @@ + + + + + + + +Horizontal and vertical scrolling + + + +In this example you can see DataTables doing horizontal and vertical scrolling at the same time. Note also that pagination is enabled, and the scrolling accounts for this. + + + diff --git a/examples_src/basic_init/scroll_y.xml b/examples_src/basic_init/scroll_y.xml new file mode 100644 index 00000000..eeb9f606 --- /dev/null +++ b/examples_src/basic_init/scroll_y.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + +This example shows the DataTables table body scrolling in the vertical direction. This can generally be seen as an alternative method to pagination for displaying a large table in a fairly small vertical area, and as such pagination has been disabled here (note that this is not mandatory, it will work just fine with pagination enabled as well!). The example is set up to show grid lines using CSS, which is useful for alignment, both for testing and end user usability. To enable y scrolling simply set the scrollY parameter to be whatever you want the container wrapper's height to be (any CSS measurement is acceptable, or just a number which is treated as pixels). + + + diff --git a/examples_src/basic_init/scroll_y_infinite.xml b/examples_src/basic_init/scroll_y_infinite.xml new file mode 100644 index 00000000..c8ba523a --- /dev/null +++ b/examples_src/basic_init/scroll_y_infinite.xml @@ -0,0 +1,25 @@ + + + + + + + +Infinite vertical scrolling + + + +

This example shows the DataTables table body scrolling in the vertical direction with infinite scrolling. The idea of infinite scrolling means that data will be added to the table dynamically, as and when needed by the user scrolling the table. A sub-set of the data is loaded initially, and more added as needed (technically of course, it is not "infinite" since it will stop loading data at the end of the data set!). Note that pagination much be enabled for infinite scrolling to work, but the pagination controls will not be shown (they could be, but can cause very confusing user interaction).

+ +

DataTables' infinite scroll can be used with any of the four data sources supported, and they do not require any modification to work (including server-side scripts).

+
+ +
diff --git a/examples_src/basic_init/scroll_y_theme.xml b/examples_src/basic_init/scroll_y_theme.xml new file mode 100644 index 00000000..8585ab41 --- /dev/null +++ b/examples_src/basic_init/scroll_y_theme.xml @@ -0,0 +1,24 @@ + + + + + + + + +Vertical scrolling with jQuery UI ThemeRoller + + + +This example is an extension of the vertical scrolling example, showing DataTables ability to be themed by jQuery UI's ThemeRoller. + + + diff --git a/examples_src/basic_init/state_save.xml b/examples_src/basic_init/state_save.xml new file mode 100644 index 00000000..1fe2f9c5 --- /dev/null +++ b/examples_src/basic_init/state_save.xml @@ -0,0 +1,19 @@ + + + + + + + +State saving + + + +DataTables can use cookies in the end user's web-browser in order to store it's state after each change in drawing. What this means is that if the user were to reload the page, the table should remain exactly as it was (length, filtering, pagination and sorting). This feature is disabled by default, but can be easily enabled using the stateSave initialisation parameter as shown in this example. Note also that the duration of the cookie can be set using the stateDuration initialisation parameter (which is in seconds). + + + diff --git a/examples_src/basic_init/table_sorting.xml b/examples_src/basic_init/table_sorting.xml new file mode 100644 index 00000000..badbda02 --- /dev/null +++ b/examples_src/basic_init/table_sorting.xml @@ -0,0 +1,21 @@ + + + + + + + +Default sorting + + + +With DataTables you can alter the sorting characteristics of the table at initialisation time. Using the sorting initialisation parameter, you can get the table exactly how you want to present the information. The sorting parameter is an array of arrays where the first value is the column to sort on, and the second is 'asc' or 'desc' as required (it is a double array for multi-column sorting). The table below is sorted (descending) by the CSS grade. Note also that the 'Engine version' column is automatically detected as a numeric column and sorted accordingly. + + + diff --git a/examples_src/basic_init/themes.xml b/examples_src/basic_init/themes.xml new file mode 100644 index 00000000..6960ab2b --- /dev/null +++ b/examples_src/basic_init/themes.xml @@ -0,0 +1,23 @@ + + + + + + + + +jQuery UI themes + + + +Styling widgets such as DataTables can often take a considerable amount of time to fully integrate it into your site / application, with the demo styles as a base. This holds true for all widgets, and the jQuery UI team have addressed this issue by introducing themes through their excellent ThemeRoller. DataTables has full support for ThemeRoller created themes, all you need to do is enable the jQueryUI flag in the initialisation object, and the required mark-up and classes will be added by DataTables. + + + diff --git a/examples_src/basic_init/zero_config.xml b/examples_src/basic_init/zero_config.xml new file mode 100644 index 00000000..2cc6d041 --- /dev/null +++ b/examples_src/basic_init/zero_config.xml @@ -0,0 +1,19 @@ + + + + + + + +Zero configuration + + + + DataTables has most features enabled by default, so all you need to do to use it with one of your own tables is to call the construction function (as shown below). + + +