Questions tagged [datatables]

DataTables is a plug-in for the jQuery JavaScript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. Do not use this together with [datatable].

DataTables is a for the . It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction to any .

Do not confuse this tag with which is for table constructs in other languages like .NET's DataTable type! Using both tags together should only be done when displaying .NET DataTable content as jQuery DataTables in a web page.

##Key features:##

  • Variable length pagination
  • On-the-fly filtering
  • Multi-column sorting with data type detection
  • Smart handling of formatted data for display, filtering and sorting
  • Smart handling of column widths
  • Display data from almost any data source
  • DOM, JavaScript array, Ajax file and server-side processing (PHP, C#, Perl, Ruby, AIR, Gears, Python, etc.)
  • Scrolling options for table viewport
  • Supports internationalization
  • jQuery UI ThemeRoller support
  • Rock solid - backed by a suite of 2600+ unit tests
  • Wide variety of plug-ins inc. TableTools, FixedColumns, KeyTable and more
  • It's free!

##Resources:##

##Coding:##

Add recent version of all libraries

<link  href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.21/css/jquery.dataTables.min.css" rel="stylesheet" >
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.21/js/jquery.dataTables.min.js"></script>

###Default HTML table###

For DataTables to be able to enhance an HTML table, the table must be valid, well formatted HTML, with a header (thead) and a body (tbody). An optional footer (tfoot) can also be used.

<table id="example" class="display">
   <thead>
      <tr>
         <th>Company name</th>
         <th>Address</th>
         <th>Town</th>
      </tr>
    </thead>
    <tbody>
       <tr>
          <td>Emkay Entertainments</td>
          <td>Nobel House, Regent Centre</td>
          <td>Lothian</td>
       </tr>
       <tr>
          <td>The Empire</td>
          <td>Milton Keynes Leisure Plaza</td>
          <td>Buckinghamshire</td>
       </tr>
    </tbody>
</table>

###Initializing the plugins:###

After the proper include of the required JavaScript/JQuery libraries the plug-in can be initialized with a few line of code. The text following the # character and the id attribute of the table must be identical.

$(document).ready(function() {
    $('#example').dataTable();
});

###Fiddle:###

  • When asking questions it is a good idea to provide a Fiddle or JS Bin which reproduces your problem. This greatly increases the possibility for others to debug your problems.
20644 questions
4
votes
1 answer

JQUERY DataTable FnServer Data not called on second time event(Button Click)

Am using JQUERY DataTable and am loading Data using fnserverdata Ajax calls. When i click serach button for first time 'fnServerData':function(sSource, aoData, fnCallback) { console.log("Called"); $.ajax({ . . . }) my…
Peru
  • 2,871
  • 5
  • 37
  • 66
4
votes
1 answer

jQuery DataTable Inline Editing

I have been trying to implement simple Inline editing in jQuery Datatable. But I cannot activate the edit that happens on click on a row cell. I used the same code as in their site Link:
lbrahim
  • 3,710
  • 12
  • 57
  • 95
4
votes
1 answer

DataTables - Using Column Names Instead of Indexes

I have a DataTables setup as follows. var pageData = [ { "id":"2", "slug":"about\/history", "title":"History", "last_updated":"2013-04-21 09:50:41" }, { "id":"3", "slug":"about", …
Jomoos
  • 12,823
  • 10
  • 55
  • 92
4
votes
2 answers

datatables and server-side processing - load on demand

I've build simple table using DataTables and I successfully connected server-side script to populate my table with data. Above my table I have 2 checkboxes and 2 date selects to specify filter criterias. When my page is loading I get table filled,…
Misiu
  • 4,738
  • 21
  • 94
  • 198
4
votes
1 answer

jQuery datatable custom sorting and filtering

I am using jquery datatables in my MVC4 application. The most simple configuration of jquery datatables. Infact, I have placed this small jquery snippet in my layout.cshtml file which will take care of all tables in my application without doing…
Bilal Fazlani
  • 6,727
  • 9
  • 44
  • 90
4
votes
2 answers

JQuery DataTables mRender - how do I get the row ID?

With the JQuery DataTables plugin I am using mRender to add buttons to my dynamically added rows. This part works great, but how can I get the rowID of the current row the buttons are added to? I need this to create unique IDs for the buttons. What…
elizabethmeyer
  • 953
  • 2
  • 9
  • 13
4
votes
3 answers

Jquery Datatables populate after form post

I'm trying to do a form submit (POST) with some parameters and based on the parameters I want to populate my datatable. But I'm not very good with Javascript (My language is Java), so I'm trying to do it with an Ajax call. But it won't work for me.…
Danny Gloudemans
  • 2,597
  • 7
  • 39
  • 57
4
votes
3 answers

sAjaxSource Params

If I have a sAjaxSource can i pass parameters through that to make my page more flexiable? Here is how I have it now: "sAjaxSource": "Data/IndustryTable?region_type=4®ion_code=51&ind_min=10&ind_max=99" The end goal is that when a user lands on…
Troy Bryant
  • 994
  • 8
  • 29
  • 60
4
votes
1 answer

Jquery Datatables - Get all rows even if not on current page

I'm using the Datatables.net plugin for JQuery. I am trying to create a "Totals" row in the footer. I'm using this example as a reference: http://datatables.net/release-datatables/examples/advanced_init/footer_callback.html Does the array aiDisplay…
kralco626
  • 8,456
  • 38
  • 112
  • 169
4
votes
1 answer

Crossfilter filter based on textbox

I would like to filter my data based on the input in a textbox. Is this possible? Something like this but with crossfilter.
Pieter_Daems
  • 1,234
  • 2
  • 14
  • 20
4
votes
2 answers

datatables bootstrap pagination - only show previous / next

Been integrating the jquery DataTables plugin to my rails app, via the rweng/jquery-datatables-rails gem. It's awesome. I even went so far as to style it with bootstrap. So, I have bootstrap, and kaminari for pagination (not sure if that matters).…
Dudo
  • 4,002
  • 8
  • 32
  • 57
4
votes
2 answers

datatables summarise filtered data

I'm using datatable jquery plugin in my site. All working well. However I'm trying to enhance the table by using the plugin script column filter and then I want to summarise the data in the footer. I can get the filter to work correctly. An example…
Ray
  • 3,018
  • 8
  • 50
  • 91
4
votes
2 answers

Cannot read property 'asSorting' of undefined - DataTables

for ( j=0, jLen=oColumn.asSorting.length ; j and
Dudo
  • 4,002
  • 8
  • 32
  • 57
4
votes
2 answers

checking for null in lambda expression - linq

I am attempting to write an expression for an advanced search. However, I need to check if each property is null, otherwise an error will be thrown. I have included the expression without the null checking below. The result is output using jQuery…
jjc99
  • 3,559
  • 4
  • 22
  • 21
4
votes
5 answers

Datatable colspan sorting

Datatable jquery plugin gives error when colspan or rowspan is introduced. Is there any other way of getting through it.
jerin john
  • 203
  • 1
  • 4
  • 11
1 2 3
99
100