Method Destroy DataTables
up vote
0
down vote
favorite
I have in my page, many tables.
They are initialized with DataTables jquery with keytable plugins.
When i use method $("#mytable1").destroy()
in a espefic table, all others lose keytable.
Anybody know why this happing?
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test Table</title>
<!-- Bootstrap -->
<link href="gentemplate/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.18/af-2.3.2/b-1.5.4/cr-1.5.0/fc-3.2.5/kt-2.5.0/sc-1.5.0/sl-1.2.6/datatables.min.css"/>
</head>
<body>
<table id="example" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<button onclick="active()" type="button">Active</button>
<table id="example3" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<table id="example2" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/datatable/datatables.js"></script>
<script>
$(document).ready(function() {
var table = $('#example').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
var table2 = $('#example2').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
} );
function active(){
if(isDataTable("example3")){
$('#example3').DataTable().destroy();
}
$('#example3').DataTable( {
deferRender: true,
scrollY: 400,
scrollCollapse: true,
keys: true
} );
}
function isDataTable(idGrid) {
return $.fn.DataTable.isDataTable("#" + idGrid);
}
</script>
</body>
</html>
Test flow:
- Click active, check all table have key navigation.
- Click active again, only example3 have key navigation
javascript jquery datatables jquery-plugins
|
show 1 more comment
up vote
0
down vote
favorite
I have in my page, many tables.
They are initialized with DataTables jquery with keytable plugins.
When i use method $("#mytable1").destroy()
in a espefic table, all others lose keytable.
Anybody know why this happing?
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test Table</title>
<!-- Bootstrap -->
<link href="gentemplate/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.18/af-2.3.2/b-1.5.4/cr-1.5.0/fc-3.2.5/kt-2.5.0/sc-1.5.0/sl-1.2.6/datatables.min.css"/>
</head>
<body>
<table id="example" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<button onclick="active()" type="button">Active</button>
<table id="example3" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<table id="example2" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/datatable/datatables.js"></script>
<script>
$(document).ready(function() {
var table = $('#example').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
var table2 = $('#example2').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
} );
function active(){
if(isDataTable("example3")){
$('#example3').DataTable().destroy();
}
$('#example3').DataTable( {
deferRender: true,
scrollY: 400,
scrollCollapse: true,
keys: true
} );
}
function isDataTable(idGrid) {
return $.fn.DataTable.isDataTable("#" + idGrid);
}
</script>
</body>
</html>
Test flow:
- Click active, check all table have key navigation.
- Click active again, only example3 have key navigation
javascript jquery datatables jquery-plugins
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have in my page, many tables.
They are initialized with DataTables jquery with keytable plugins.
When i use method $("#mytable1").destroy()
in a espefic table, all others lose keytable.
Anybody know why this happing?
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test Table</title>
<!-- Bootstrap -->
<link href="gentemplate/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.18/af-2.3.2/b-1.5.4/cr-1.5.0/fc-3.2.5/kt-2.5.0/sc-1.5.0/sl-1.2.6/datatables.min.css"/>
</head>
<body>
<table id="example" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<button onclick="active()" type="button">Active</button>
<table id="example3" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<table id="example2" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/datatable/datatables.js"></script>
<script>
$(document).ready(function() {
var table = $('#example').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
var table2 = $('#example2').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
} );
function active(){
if(isDataTable("example3")){
$('#example3').DataTable().destroy();
}
$('#example3').DataTable( {
deferRender: true,
scrollY: 400,
scrollCollapse: true,
keys: true
} );
}
function isDataTable(idGrid) {
return $.fn.DataTable.isDataTable("#" + idGrid);
}
</script>
</body>
</html>
Test flow:
- Click active, check all table have key navigation.
- Click active again, only example3 have key navigation
javascript jquery datatables jquery-plugins
I have in my page, many tables.
They are initialized with DataTables jquery with keytable plugins.
When i use method $("#mytable1").destroy()
in a espefic table, all others lose keytable.
Anybody know why this happing?
<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Test Table</title>
<!-- Bootstrap -->
<link href="gentemplate/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.18/af-2.3.2/b-1.5.4/cr-1.5.0/fc-3.2.5/kt-2.5.0/sc-1.5.0/sl-1.2.6/datatables.min.css"/>
</head>
<body>
<table id="example" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<button onclick="active()" type="button">Active</button>
<table id="example3" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<hr />
<table id="example2" class="display table" style="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>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/datatable/datatables.js"></script>
<script>
$(document).ready(function() {
var table = $('#example').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
var table2 = $('#example2').DataTable( {
deferRender: true,
scrollY: 200,
scrollCollapse: true,
keys: true
} );
} );
function active(){
if(isDataTable("example3")){
$('#example3').DataTable().destroy();
}
$('#example3').DataTable( {
deferRender: true,
scrollY: 400,
scrollCollapse: true,
keys: true
} );
}
function isDataTable(idGrid) {
return $.fn.DataTable.isDataTable("#" + idGrid);
}
</script>
</body>
</html>
Test flow:
- Click active, check all table have key navigation.
- Click active again, only example3 have key navigation
javascript jquery datatables jquery-plugins
javascript jquery datatables jquery-plugins
edited Nov 13 at 11:49
MyTwoCents
2,7341827
2,7341827
asked Nov 12 at 17:33
Thiago Miranda
62
62
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50
|
show 1 more comment
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
As per this example you need to import keyTable js and css files
js and css files
https://cdn.datatables.net/keytable/2.4.1/js/dataTables.keyTable.min.js
https://cdn.datatables.net/keytable/2.4.1/css/keyTable.dataTables.min.css
In Datatable initialiser just add keys
attr like this
$('#example').DataTable( {
keys: true
});
Working jsfiddle
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As per this example you need to import keyTable js and css files
js and css files
https://cdn.datatables.net/keytable/2.4.1/js/dataTables.keyTable.min.js
https://cdn.datatables.net/keytable/2.4.1/css/keyTable.dataTables.min.css
In Datatable initialiser just add keys
attr like this
$('#example').DataTable( {
keys: true
});
Working jsfiddle
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
add a comment |
up vote
0
down vote
As per this example you need to import keyTable js and css files
js and css files
https://cdn.datatables.net/keytable/2.4.1/js/dataTables.keyTable.min.js
https://cdn.datatables.net/keytable/2.4.1/css/keyTable.dataTables.min.css
In Datatable initialiser just add keys
attr like this
$('#example').DataTable( {
keys: true
});
Working jsfiddle
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
add a comment |
up vote
0
down vote
up vote
0
down vote
As per this example you need to import keyTable js and css files
js and css files
https://cdn.datatables.net/keytable/2.4.1/js/dataTables.keyTable.min.js
https://cdn.datatables.net/keytable/2.4.1/css/keyTable.dataTables.min.css
In Datatable initialiser just add keys
attr like this
$('#example').DataTable( {
keys: true
});
Working jsfiddle
As per this example you need to import keyTable js and css files
js and css files
https://cdn.datatables.net/keytable/2.4.1/js/dataTables.keyTable.min.js
https://cdn.datatables.net/keytable/2.4.1/css/keyTable.dataTables.min.css
In Datatable initialiser just add keys
attr like this
$('#example').DataTable( {
keys: true
});
Working jsfiddle
answered Nov 13 at 14:40
MyTwoCents
2,7341827
2,7341827
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
add a comment |
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
In my example "lib/datatable/datatables.js" keytable are concatenated. Datatables itself give me that option. Verify in this example, keys working right. When you click in destroy, keytable stoped in all tables. live.datatables.net/vinerahu/2/edit
– Thiago Miranda
Nov 13 at 15:17
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267294%2fmethod-destroy-datatables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Pls, add some code showing how you have added keytable and how you are destroying and where.
– MyTwoCents
Nov 13 at 7:06
Ok i go post in a answer, because i cant edit my question.
– Thiago Miranda
Nov 13 at 11:10
Ok I have edited your question you can delete ans
– MyTwoCents
Nov 13 at 11:21
Okey. Thank you
– Thiago Miranda
Nov 13 at 11:33
So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1
– MyTwoCents
Nov 13 at 11:50