Jquery datatable plugin not working in html table
Jquery datatable plugin not working in html table
I am trying to use the DataTable plugin to add functionality to my html table. I followed the steps for installation and initialization from datatables.net, but it is not adding any functionality to my html page. I am wondering if it is because my table is formatted in a way that isn't supported by the plug-in. Any input would be useful. Thanks a lot!
<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"</script>
<script>
$(document).ready(function(){
$('#example').DataTable();
});
</script>
</head>
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
Answers
Your HTML has no closing "table" tag.
I'm using following code in a local .html file and load it in the browser, but datatables does not get applied. Can someone please help.
Edited by Allan - Markdown syntax highlighting
for a basic table, after your jQuery includes, try these
That needs to be in script tags.
Are there any errors or warnings shown on your browser's console?
If not, please link to a test page showing the issue so we can check it out.
Allan
Hi
This code is not working for me please suggest me
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/dataTables.jqueryui.min.css" />
</head>
<body>
<div>
</body>
</html>
DataTables requires jQuery. It's not referenced in your HTML.
Looks like you are missing some JS and CSS includes, like jquery.js. The easiest way to get all the needed files is with the download builder:
https://datatables.net/download/index
Kevin
it's not initialised with data table sort and search. If there is no data for empty table it is getting initialized
Thanks,
Venkat
Are you getting any alert errors or errors in the browser's console?
Without seeing the actual problem its hard to say what is happening. Can you post a link to your page or provide a test case with the issue?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Can you try with just one row? Maybe you can take that data and build a test case for us.
Kevin
Hello I am geting the huge table from api listing is not working in datatable whenever i select any no of list its showing only one row at a time and in first time instead of shoiwng 10 lines its showing all data please help i am newbie i am attaching the code following
Can you link to the page showing the issue so we can help to debug it please? It isn't immediately obvious from the above what is going wrong.
That said, the one thing that does stand out for me is that you are initialising the DataTable inside your double
for
loops (i.e. after every row is added). That's not going to work. Move it to outside of yourfor
loops.Allan
I have the similar problem (plugin not worked) when used jquery library v2.
It works with jquery 3
thanks for this.. its very helpful for me...
i am creating the datatable included the javascript but my table is just showing one row that is undefined. i have tried so many things but nothing is working.
code is below:
You haven't said why it isn't working? Are you seeing errors?
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin