MEVIS3000
MEVIS3000

Reputation: 561

jquery DataTable function options are not working

I want to change some settings of my table with DataTable function, but the arguments

paging: false,
scrollY: 400

are not having any effect on the table whatsoever.


<html>
<head>
  <meta charset=utf-8 />
  <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
</head>
<body>


<table id='example'>
  <thead>
    <tr><th class='site_name'>Name</th><th>Url </th><th>Type</th><th>Last modified</th></tr>
  </thead>
  <tbody>
  </tbody>
</table>


  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>

  <script>

$("#example").DataTable({
  "aaData":[
    ["Sitepoint","http://sitepoint.com","Blog","2013-10-15 10:30:00"],
    ["Flippa","http://flippa.com","Marketplace","null"],
    ["99designs","http://99designs.com","Marketplace","null"],
    ["Learnable","http://learnable.com","Online courses","null"],
    ["Rubysource","http://rubysource.com","Blog","2013-01-10 12:00:00"]
  ],
    paging: false,
    scrollY: 400
}
);

  </script>
</body>
</html>

I took the code from https://www.sitepoint.com/working-jquery-datatables/ and the instructions for the options from https://datatables.net/manual/options.

Upvotes: 0

Views: 2273

Answers (2)

gaetanoM
gaetanoM

Reputation: 42054

As you can see in the documentation :

paging: Enable or disable table pagination. Since: DataTables 1.10

This means you have to change the libraries version:

$("#example").DataTable({
  "aaData":[
    ["Sitepoint","http://sitepoint.com","Blog","2013-10-15 10:30:00"],
    ["Flippa","http://flippa.com","Marketplace","null"],
    ["99designs","http://99designs.com","Marketplace","null"],
    ["Learnable","http://learnable.com","Online courses","null"],
    ["Learnable","http://learnable.com","Online courses","null"],
    ["Learnable","http://learnable.com","Online courses","null"],
    ["Rubysource","http://rubysource.com","Blog","2013-01-10 12:00:00"]
  ],
  paging: false,
  scrollY: 400
}
                       );
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>


<table id='example'>
    <thead>
    <tr><th class='site_name'>Name</th><th>Url </th><th>Type</th><th>Last modified</th></tr>
    </thead>
    <tbody>
    </tbody>
</table>

Upvotes: 2

Rajshekar Reddy
Rajshekar Reddy

Reputation: 19007

This is how you do to the Datatables version < 1.10

"bPaginate": false,
"sScrollY": "400px",

Upvotes: 1

Related Questions