Method Destroy DataTables










0















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:



  1. Click active, check all table have key navigation.

  2. Click active again, only example3 have key navigation









share|improve this question
























  • Pls, add some code showing how you have added keytable and how you are destroying and where.

    – MyTwoCents
    Nov 13 '18 at 7:06











  • Ok i go post in a answer, because i cant edit my question.

    – Thiago Miranda
    Nov 13 '18 at 11:10











  • Ok I have edited your question you can delete ans

    – MyTwoCents
    Nov 13 '18 at 11:21











  • Okey. Thank you

    – Thiago Miranda
    Nov 13 '18 at 11:33











  • So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

    – MyTwoCents
    Nov 13 '18 at 11:50















0















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:



  1. Click active, check all table have key navigation.

  2. Click active again, only example3 have key navigation









share|improve this question
























  • Pls, add some code showing how you have added keytable and how you are destroying and where.

    – MyTwoCents
    Nov 13 '18 at 7:06











  • Ok i go post in a answer, because i cant edit my question.

    – Thiago Miranda
    Nov 13 '18 at 11:10











  • Ok I have edited your question you can delete ans

    – MyTwoCents
    Nov 13 '18 at 11:21











  • Okey. Thank you

    – Thiago Miranda
    Nov 13 '18 at 11:33











  • So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

    – MyTwoCents
    Nov 13 '18 at 11:50













0












0








0








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:



  1. Click active, check all table have key navigation.

  2. Click active again, only example3 have key navigation









share|improve this question
















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:



  1. Click active, check all table have key navigation.

  2. Click active again, only example3 have key navigation






javascript jquery datatables jquery-plugins






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 11:49









MyTwoCents

3,0242928




3,0242928










asked Nov 12 '18 at 17:33









Thiago MirandaThiago Miranda

62




62












  • Pls, add some code showing how you have added keytable and how you are destroying and where.

    – MyTwoCents
    Nov 13 '18 at 7:06











  • Ok i go post in a answer, because i cant edit my question.

    – Thiago Miranda
    Nov 13 '18 at 11:10











  • Ok I have edited your question you can delete ans

    – MyTwoCents
    Nov 13 '18 at 11:21











  • Okey. Thank you

    – Thiago Miranda
    Nov 13 '18 at 11:33











  • So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

    – MyTwoCents
    Nov 13 '18 at 11:50

















  • Pls, add some code showing how you have added keytable and how you are destroying and where.

    – MyTwoCents
    Nov 13 '18 at 7:06











  • Ok i go post in a answer, because i cant edit my question.

    – Thiago Miranda
    Nov 13 '18 at 11:10











  • Ok I have edited your question you can delete ans

    – MyTwoCents
    Nov 13 '18 at 11:21











  • Okey. Thank you

    – Thiago Miranda
    Nov 13 '18 at 11:33











  • So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

    – MyTwoCents
    Nov 13 '18 at 11:50
















Pls, add some code showing how you have added keytable and how you are destroying and where.

– MyTwoCents
Nov 13 '18 at 7:06





Pls, add some code showing how you have added keytable and how you are destroying and where.

– MyTwoCents
Nov 13 '18 at 7:06













Ok i go post in a answer, because i cant edit my question.

– Thiago Miranda
Nov 13 '18 at 11:10





Ok i go post in a answer, because i cant edit my question.

– Thiago Miranda
Nov 13 '18 at 11:10













Ok I have edited your question you can delete ans

– MyTwoCents
Nov 13 '18 at 11:21





Ok I have edited your question you can delete ans

– MyTwoCents
Nov 13 '18 at 11:21













Okey. Thank you

– Thiago Miranda
Nov 13 '18 at 11:33





Okey. Thank you

– Thiago Miranda
Nov 13 '18 at 11:33













So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

– MyTwoCents
Nov 13 '18 at 11:50





So here is the working code. What exactly is issue. jsfiddle.net/j5oha0mc/1

– MyTwoCents
Nov 13 '18 at 11:50












1 Answer
1






active

oldest

votes


















0














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






share|improve this answer























  • 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 '18 at 15:17










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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






share|improve this answer























  • 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 '18 at 15:17















0














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






share|improve this answer























  • 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 '18 at 15:17













0












0








0







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






share|improve this answer













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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 14:40









MyTwoCentsMyTwoCents

3,0242928




3,0242928












  • 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 '18 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 '18 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 '18 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 '18 at 15:17



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo