{"id":17272,"date":"2017-06-07T16:15:36","date_gmt":"2017-06-07T13:15:36","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=17272"},"modified":"2017-12-21T15:24:49","modified_gmt":"2017-12-21T13:24:49","slug":"jquery-datatable-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/","title":{"rendered":"JQuery Datatable Example"},"content":{"rendered":"<p>Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using the JQuery Data table API and also we will check some details about this API. Before we start, check the requirements related to the technologies and the frameworks used to the example below:<\/p>\n<ol>\n<li>jquery 3.2.1<\/li>\n<li>jquery datatable plugin 1.10.15<\/li>\n<li>HTML<\/li>\n<li>CSS<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>1. Introduction<\/h2>\n<p>A DataTable is a JQuery\u00b4s plugin for creating HTML tables using the JQuery&#8217;s DOM manipulation power, this plugin allows add interactions to them. Interactions like searching, sorting, and pagination without configuration.<\/p>\n<p>DataTable and its extensions provide an extensive API that allows manipulating the data contained in the table. The design of this API represents the structure of the data on the table and provide ways to interact with the table. The API have 6 key areas to work with a table and its data:<\/p>\n<ul>\n<li>Tables<\/li>\n<li>Columns<\/li>\n<li>Rows<\/li>\n<li>Cells<\/li>\n<li>Core<\/li>\n<li>Utilities<\/li>\n<\/ul>\n<p>The DataTable API provides a set of extensions and plugins that add more functionality to the methods exposed through this API. To see the currently available extensions and plugins check the links below:<\/p>\n<ul>\n<li><a href=\"https:\/\/datatables.net\/extensions\">Extensions<\/a><\/li>\n<li><a href=\"https:\/\/datatables.net\/manual\/plug-ins\/api\">Plugins<\/a><\/li>\n<\/ul>\n<p>For the full API methods documentation please refer to <a href=\"https:\/\/datatables.net\/reference\/api\">API reference<\/a><\/p>\n<h2>2. Concepts<\/h2>\n<p>In order to be clear on some API concepts for the development of these examples, below I&#8217;ll explain a few important concepts to keep in mind for this implementation.<\/p>\n<ul>\n<li>Instance: Is a simple API object that refers to a specific set of DataTables.<\/li>\n<li>Result set: Is the data that is held for the API instance, comes in a javascript array way and you can access it using array notation.<code>[]<\/code><\/li>\n<li>Context: Describe the API DataTables linked with the instance, using this context you can access to one or more DataTables and interact with them.<\/li>\n<\/ul>\n<h2>3. Using The API<\/h2>\n<p>On this section, we&#8217;ll see the different ways that allow obtaining an API instance for one or more tables. The API provides 3 ways to access to it, these ways are:<\/p>\n<ul>\n<li><code>$( selector ).DataTable();<\/code><\/li>\n<li><code><\/code><code>$( selector ).dataTable().api();<\/code><\/li>\n<li><code><\/code><code>new $.fn.dataTable.Api( selector );<\/code><\/li>\n<\/ul>\n<p>The result of each way is a DataTables API instance that has the tables found by the selector. It is an important difference between <code>$( selector ).DataTable();<\/code> and <code>$( selector ).dataTable();<\/code>. The first one returns a DataTables instance, while the second one returns a <code>jQuery type<\/code> object. An <code>api()<\/code> method allows converting that JQuery object on a DataTables API instance.<\/p>\n<p>The JQuery object created by the <code>$( selector ).dataTable();<\/code> can be useful to manipulate the table node like any other JQuery object.<\/p>\n<h2>4. Chainig<\/h2>\n<p>This JQuery API feature allows the DataTables API to be used in an extensive way. This applies for methods that return the DataTable API instance, so you can call immediately another API method like is shown below.<\/p>\n<pre class=\"brush:js\">var table = $('#wcg_example').DataTable();\r\n \r\ntable.search( 'Carlos' ).draw();\r\n<\/pre>\n<p>In this code example, we are using the <code>search<\/code> and <code>draw<\/code> API, on a single line. This can be helpful to make our code shorter and clear.<\/p>\n<h2>5. Setup Environment<\/h2>\n<p>For implementing this example we need the next tools:<\/p>\n<ol>\n<li>Web Browser (Chrome, FireFox, etc..), to check the Jquery browser compatibility please check <a href=\"https:\/\/jquery.com\/browser-support\/\">this<\/a> URL<\/li>\n<li>Text Editor (ATOM, Brackets, Notepad++, etc..)<\/li>\n<\/ol>\n<p>In order to implement these examples, we\u2019ll use the JQuery CDN. Also, you can download the JQuery library on a non-minified version for development purposes from <a href=\"http:\/\/jquery.com\/download\/\">here<\/a>.<\/p>\n<p>Also, we&#8217;ll use the DataTable CDN. In order to know how to use the CDN please refer to <a href=\"https:\/\/cdn.datatables.net\/\">datatables.net<\/a>.\u00a0Also you can download the source code for development purposes with dependencies management tools like <a href=\"https:\/\/www.npmjs.com\/\">NPM<\/a> and\u00a0<a href=\"https:\/\/bower.io\/\">Bower<\/a>.<\/p>\n<h2>6. Examples Implementation<\/h2>\n<p>In order to implement a JQuery data table it is first necessary to create a well formatted HTML table.<\/p>\n<h3>6.1 HTML Table<\/h3>\n<p>To use the JQuery data table we need to create an HTML table following the structure below:<\/p>\n<pre class=\"brush:xml\">&lt;table id=\"wgc_table\" class=\"display\"&gt;\r\n    &lt;thead&gt;\r\n        &lt;tr&gt;\r\n            &lt;th&gt;Column 1&lt;\/th&gt;\r\n            &lt;th&gt;Column 2&lt;\/th&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 1 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 1 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 2 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 2 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n<\/pre>\n<p>The previous table must have the tags <code>thead<\/code> and <code>tbody.<\/code>\u00a0Also like optional you can use the <code>tfoot<\/code> tag. So this is the stantard html table structure that allows to integrate the JQuery data table with our html table.<\/p>\n<h3>6.2 JQuery DataTable Basic Initialization Example<\/h3>\n<p>In this example, we&#8217;ll see how to create a basic JQuery data table using the DataTable API and an HTML table. Please check the code below to see the implementation.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>basic_datatable_initialization_example.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;!-- Using the jquery CDN --&gt;\r\n&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;!-- Using the jquery dataTables CSS CDN --&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"\/\/cdn.datatables.net\/1.10.15\/css\/jquery.dataTables.css\"&gt;\r\n&lt;!-- Using the jquery dataTables API CDN --&gt;\r\n&lt;script type=\"text\/javascript\" charset=\"utf8\" src=\"\/\/cdn.datatables.net\/1.10.15\/js\/jquery.dataTables.js\"&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    \r\n    &lt;!-- Target table to instantiate the DataTable API --&gt;\r\n    &lt;table id=\"wgc_table\" class=\"display\"&gt;\r\n    &lt;thead&gt;\r\n        &lt;tr&gt;\r\n            &lt;th&gt;Column 1&lt;\/th&gt;\r\n            &lt;th&gt;Column 2&lt;\/th&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 1 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 1 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 2 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 2 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n    &lt;!-- JQuery code to initializate the DataTables API --&gt;\r\n    &lt;script&gt;\r\n      $(document).ready( function () {\r\n           $('#wgc_table').DataTable();\/\/Basic DataTable API instance \r\n        });\r\n    &lt;\/script&gt;\r\n\r\n&lt;\/body&gt; \r\n&lt;\/html&gt;\r\n<\/pre>\n<p>The output of the previous example shows us a default JQuery data table with some other default components provided by the API like a paginator, search text box, sorting component, and a default CSS style. See the output below.<\/p>\n<figure id=\"attachment_17310\" aria-describedby=\"caption-attachment-17310\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/basic_jquery_table-1.png\"><img decoding=\"async\" class=\"wp-image-17310 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/basic_jquery_table-1.png\" alt=\"\" width=\"860\" height=\"270\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/basic_jquery_table-1.png 860w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/basic_jquery_table-1-300x94.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/basic_jquery_table-1-768x241.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-17310\" class=\"wp-caption-text\">Figure 1. Basic jquery data table<\/figcaption><\/figure>\n<h3>6.3 JQuery DataTable Advanced Initialization Example<\/h3>\n<p>In this example, we&#8217;ll see how to create a JQuery data table using an advanced DataTable API initialization. In this case data table events like order, search and page. For these events we will add a notification function that will be fired when the data table event occurs. Please check the code below to see the implementation.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>advanced_datatable_initialization_example.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;!-- Using the jquery CDN --&gt;\r\n&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;!-- Using the jquery dataTables CSS CDN --&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"\/\/cdn.datatables.net\/1.10.15\/css\/jquery.dataTables.css\"&gt;\r\n&lt;!-- Using the jquery dataTables API CDN --&gt;\r\n&lt;script type=\"text\/javascript\" charset=\"utf8\" src=\"\/\/cdn.datatables.net\/1.10.15\/js\/jquery.dataTables.js\"&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    \r\n    &lt;!-- Target table to instantiate the DataTable API --&gt;\r\n    &lt;table id=\"wgc_table\" class=\"display\"&gt;\r\n    &lt;thead&gt;\r\n        &lt;tr&gt;\r\n            &lt;th&gt;Column 1&lt;\/th&gt;\r\n            &lt;th&gt;Column 2&lt;\/th&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 1 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 1 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 2 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 2 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 3 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 3 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 4 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 4 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 5 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 5 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 6 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 6 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 7 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 7 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 8 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 8 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 9 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 9 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 10 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 10 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 11 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 11 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 12 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 12 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 13 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 13 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 14 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 14 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 15 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 15 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n        &lt;tr&gt;\r\n            &lt;td&gt;Row 16 Data 1&lt;\/td&gt;\r\n            &lt;td&gt;Row 16 Data 2&lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/tbody&gt;\r\n&lt;\/table&gt;\r\n    &lt;!-- Div panel for data table events --&gt;\r\n    &lt;div id=\"events_output\"&gt;\r\n    &lt;\/div&gt;\r\n    &lt;!-- JQuery code to initializate the DataTables API --&gt;\r\n    &lt;script&gt;\r\n        \/\/when the DOM is rendered\r\n    $(document).ready(function() {\r\n        \/**\r\n        This function will be fire when one of these events occurs\r\n        Order, Search and page.\r\n        This function prints a div with the name and date of the event fired. \r\n        *\/\r\n        var whenTheEventIsFired = function (eventName){\r\n            var output = $('#events_output')[0];\r\n            output.innerHTML += '&lt;div&gt;'+eventName+' event - '+new Date().getTime()+'&lt;\/div&gt;';\r\n        }\r\n        \r\n        \/**\r\n        Advanced initialization adding a function that will be executed when one of the data table events provided by the API occurs.\r\n        *\/\r\n      $('#wgc_table')\r\n        .on( 'order.dt',  function () { whenTheEventIsFired( 'Order' ); } )\/\/when the table is ordered\r\n        .on( 'search.dt', function () { whenTheEventIsFired( 'Search' ); } )\/\/when search on the table using the search text box\r\n        .on( 'page.dt',   function () { whenTheEventIsFired( 'Page' ); } )\/\/when the pagination buttons are clicked.\r\n        .DataTable();\r\n            \r\n    } );\r\n    &lt;\/script&gt;\r\n\r\n&lt;\/body&gt; \r\n&lt;\/html&gt;\r\n<\/pre>\n<p>After fired the 3 events provided by the JQuery data table API (order, search, and page) the function <code>whenTheEventIsFired<\/code> is executed and creates a new div container with the event name and the date when was executed. See the output below.<\/p>\n<figure id=\"attachment_17313\" aria-describedby=\"caption-attachment-17313\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/advance_jquery_table.png\"><img decoding=\"async\" class=\"size-full wp-image-17313\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/advance_jquery_table.png\" alt=\"\" width=\"860\" height=\"392\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/advance_jquery_table.png 860w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/advance_jquery_table-300x137.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/advance_jquery_table-768x350.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-17313\" class=\"wp-caption-text\">Figure 2. Advanced jquery data table<\/figcaption><\/figure>\n<h3>6.3 JQuery DataTable Initialization Using The API And Javascript Data Example<\/h3>\n<p>In this example, we&#8217;ll see how to create a JQuery data table using directly the DataTable API and use a Javascript array in order to initialize the table with a dynamic data. We will also see how to create on the fly a JQuery data table using just the HTML table tag. Please check the code below to see the implementation.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>api_javascript_datatable_initialization.html<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;!-- Using the jquery CDN --&gt;\r\n&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.2.1\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;!-- Using the jquery dataTables CSS CDN --&gt;\r\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"\/\/cdn.datatables.net\/1.10.15\/css\/jquery.dataTables.css\"&gt;\r\n&lt;!-- Using the jquery dataTables API CDN --&gt;\r\n&lt;script type=\"text\/javascript\" charset=\"utf8\" src=\"\/\/cdn.datatables.net\/1.10.15\/js\/jquery.dataTables.js\"&gt;&lt;\/script&gt;\r\n&lt;!-- Loading the JS script that allow us create the JQuery data table --&gt;\r\n&lt;script type=\"text\/javascript\" charset=\"utf8\" src=\"api_javascript_datatable_initialization.js\"&gt;&lt;\/script&gt;    \r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    \r\n    &lt;!-- Target table to instantiate the DataTable API --&gt;\r\n    &lt;table id=\"wgc_table\" class=\"display\"&gt;&lt;\/table&gt;\r\n\r\n&lt;\/body&gt; \r\n&lt;\/html&gt;\r\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>api_javascript_datatable_initialization.js<\/em><\/span><\/p>\n<pre class=\"brush:js\">\/**\r\nThe data that will be show by the data table\r\n*\/\r\nvar dataSet = [[\"Carlos\", \"Nixon\", \"35\"],\r\n              [\"Garrett\", \"Winters\", \"33\"],\r\n              [\"Ashton\", \"Cox\", \"31\"],\r\n              [\"Cedric\", \"Kelly\", \"38\"],\r\n              [\"Airi\", \"Satou\", \"34\"],\r\n              [\"Brielle\", \"Williamson\", \"32\"],\r\n              [\"Herrod\", \"Chandler\", \"25\"],\r\n              [\"Rhona\", \"Davidson\", \"22\"],\r\n              [\"Colleen\", \"Hurst\", \"28\"],\r\n              [\"Sonya\", \"Frost\", \"30\"],\r\n              [\"Jena\", \"Gaines\", \"27\"],\r\n              [\"Quinn\", \"Flynn\", \"20\"],\r\n              [\"Charde\", \"Marshall\", \"39\"],\r\n              [\"Haley\", \"Kennedy\", \"40\"],\r\n              [\"Tatyana\", \"Fitzpatrick\", \"23\"],\r\n              [\"Pedro\", \"Perez\", \"21\"]];\r\n\r\n\/**\r\nWhen the DOM is ready, we use the data table API to create a new one\r\nbased on a javascript array that provides the data.\r\n*\/\r\n$(document).ready(function() {\r\n    $('#wgc_table').DataTable( {\r\n        data: dataSet, \/\/data used by the data table\r\n        columns: [\r\n            { title: \"First Name\" },\/\/defining table presentation using the API\r\n            { title: \"Last Name\" },\r\n            { title: \"Age\" }\r\n        ]\r\n    });\r\n});\r\n<\/pre>\n<p>The output of the previous code will be a fully functional JQuery data table. Note that in the HTML page it was necessary just to create the table HTML tag with an ID to allows to JQuery to use that tag to create the data table using the API and define some presentation aspects like the column&#8217;s title. See the output below.<\/p>\n<figure id=\"attachment_17322\" aria-describedby=\"caption-attachment-17322\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/api_javascript_jquery_table.png\"><img decoding=\"async\" class=\"size-full wp-image-17322\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/api_javascript_jquery_table.png\" alt=\"\" width=\"860\" height=\"362\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/api_javascript_jquery_table.png 860w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/api_javascript_jquery_table-300x126.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/api_javascript_jquery_table-768x323.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-17322\" class=\"wp-caption-text\">Figure 3. API javascript data table<\/figcaption><\/figure>\n<p>The official JQuery data table site provides a lot of examples that allow you to get the \u00a0necessary knowledge and understanding to use the API and use a different kind of functionalities that this library provides.<\/p>\n<p>To see all the usage examples please refer to the official examples site <a href=\"https:\/\/datatables.net\/examples\/index\">here<\/a>.<\/p>\n<h2>7. Conclusion<\/h2>\n<p>In this post we learned how to use the JQuery data table library, some specific API aspects, and we saw some simplest examples to get more understanding about this library and its usage.<\/p>\n<p>Also, we saw the functionalities that are provided by default for this API like sort pagination and searching. This is a powerful library based on JQuery framework that allows the developers to create a fully functional data table based on a different kind of data resources like javascript data JSON or Ajax API calls with a few lines of code.<\/p>\n<p>To explore in more detail the API of this library, please refer to the official API reference <a href=\"https:\/\/datatables.net\/reference\/api\/\">here<\/a>.<\/p>\n<h2>8. Download The Source Code<\/h2>\n<p>These were a JQuery data table examples.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/06\/jquery_datatable_example.zip\"><strong>JQueryDataTableExample<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using the JQuery Data table API and also we will check some details about this API. Before we start, check the requirements related to the technologies &hellip;<\/p>\n","protected":false},"author":524,"featured_media":919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-17272","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JQuery Datatable Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JQuery Datatable Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-07T13:15:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-21T13:24:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Carlos Andres\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Carlos Andres\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\"},\"author\":{\"name\":\"Carlos Andres\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/2729178a21a97c64e59208e9d19fd34a\"},\"headline\":\"JQuery Datatable Example\",\"datePublished\":\"2017-06-07T13:15:36+00:00\",\"dateModified\":\"2017-12-21T13:24:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\"},\"wordCount\":1206,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\",\"name\":\"JQuery Datatable Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"datePublished\":\"2017-06-07T13:15:36+00:00\",\"dateModified\":\"2017-12-21T13:24:49+00:00\",\"description\":\"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JQuery Datatable Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/2729178a21a97c64e59208e9d19fd34a\",\"name\":\"Carlos Andres\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7e8236b61ec178cecdb78860ebbbcfe94ed98069ed2860c2b843eb16536c0c38?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7e8236b61ec178cecdb78860ebbbcfe94ed98069ed2860c2b843eb16536c0c38?s=96&d=mm&r=g\",\"caption\":\"Carlos Andres\"},\"description\":\"Carlos Andres has graduated from Computer Engineering in the University cooperativa de colombia. He also have a certified in Cloud Architecture from ICESI university and Development Enterprise applications with java technologies from San buenaventura University. During his career he has been involved with a large number of projects ranging from insurance to virtualization products like a programmer, software designer and architect. he works as a technical lead in the software sector where he is mainly involved with projects based on Java, SOA, microservices, cloud and front end technologies.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.linkedin.com\/in\/carlosdelarosa1\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/carlos-andres\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JQuery Datatable Example - Web Code Geeks - 2026","description":"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/","og_locale":"en_US","og_type":"article","og_title":"JQuery Datatable Example - Web Code Geeks - 2026","og_description":"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-06-07T13:15:36+00:00","article_modified_time":"2017-12-21T13:24:49+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","type":"image\/jpeg"}],"author":"Carlos Andres","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Carlos Andres","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/"},"author":{"name":"Carlos Andres","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/2729178a21a97c64e59208e9d19fd34a"},"headline":"JQuery Datatable Example","datePublished":"2017-06-07T13:15:36+00:00","dateModified":"2017-12-21T13:24:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/"},"wordCount":1206,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/","name":"JQuery Datatable Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","datePublished":"2017-06-07T13:15:36+00:00","dateModified":"2017-12-21T13:24:49+00:00","description":"Hello readers, in this article we will take a look on how to use a JQuery Data table plugin. We will learn how to implement a few simple examples using","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-datatable-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"jQuery","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/"},{"@type":"ListItem","position":4,"name":"JQuery Datatable Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/2729178a21a97c64e59208e9d19fd34a","name":"Carlos Andres","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7e8236b61ec178cecdb78860ebbbcfe94ed98069ed2860c2b843eb16536c0c38?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7e8236b61ec178cecdb78860ebbbcfe94ed98069ed2860c2b843eb16536c0c38?s=96&d=mm&r=g","caption":"Carlos Andres"},"description":"Carlos Andres has graduated from Computer Engineering in the University cooperativa de colombia. He also have a certified in Cloud Architecture from ICESI university and Development Enterprise applications with java technologies from San buenaventura University. During his career he has been involved with a large number of projects ranging from insurance to virtualization products like a programmer, software designer and architect. he works as a technical lead in the software sector where he is mainly involved with projects based on Java, SOA, microservices, cloud and front end technologies.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.linkedin.com\/in\/carlosdelarosa1\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/carlos-andres\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/524"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17272"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17272\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=17272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}