419 lines
18 KiB
HTML
419 lines
18 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<link rel="shortcut icon" type="image/ico" href="https://www.datatables.net/favicon.ico">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, user-scalable=no">
|
||
|
<title>StateRestore example - Creation Modal with Toggle</title>
|
||
|
<link rel="stylesheet" type="text/css" href="../../../../examples/resources/syntax/shCore.css">
|
||
|
<link rel="stylesheet" type="text/css" href="../../../../examples/resources/demo.css">
|
||
|
<style type="text/css" class="init">
|
||
|
|
||
|
</style>
|
||
|
<script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js"></script>
|
||
|
<script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js"></script>
|
||
|
<script defer class="init">
|
||
|
dt_demo.init({
|
||
|
libs: {"targetFramework":"","js":["jquery","datatables","staterestore","buttons","searchbuilder","searchpanes","datetime","select","scroller"],"css":["datatables","buttons","staterestore","searchbuilder","searchpanes","datetime","select","scroller"],"components":{"datatables":{"css":"..\/..\/..\/..\/css","js":"..\/..\/..\/..\/js","resolve":true},"autofill":{"css":"..\/..\/..\/..\/..\/extensions\/AutoFill\/css","js":"..\/..\/..\/..\/..\/extensions\/AutoFill\/js","resolve":true},"buttons":{"css":"..\/..\/..\/..\/..\/extensions\/Buttons\/css","js":"..\/..\/..\/..\/..\/extensions\/Buttons\/js","resolve":true},"colreorder":{"css":"..\/..\/..\/..\/..\/extensions\/ColReorder\/css","js":"..\/..\/..\/..\/..\/extensions\/ColReorder\/js","resolve":true},"editor":{"css":"..\/..\/..\/..\/..\/extensions\/Editor\/css","js":"..\/..\/..\/..\/..\/extensions\/Editor\/js","resolve":true},"fixedcolumns":{"css":"..\/..\/..\/..\/..\/extensions\/FixedColumns\/css","js":"..\/..\/..\/..\/..\/extensions\/FixedColumns\/js","resolve":true},"fixedheader":{"css":"..\/..\/..\/..\/..\/extensions\/FixedHeader\/css","js":"..\/..\/..\/..\/..\/extensions\/FixedHeader\/js","resolve":true},"keytable":{"css":"..\/..\/..\/..\/..\/extensions\/KeyTable\/css","js":"..\/..\/..\/..\/..\/extensions\/KeyTable\/js","resolve":true},"responsive":{"css":"..\/..\/..\/..\/..\/extensions\/Responsive\/css","js":"..\/..\/..\/..\/..\/extensions\/Responsive\/js","resolve":true},"rowgroup":{"css":"..\/..\/..\/..\/..\/extensions\/RowGroup\/css","js":"..\/..\/..\/..\/..\/extensions\/RowGroup\/js","resolve":true},"rowreorder":{"css":"..\/..\/..\/..\/..\/extensions\/RowReorder\/css","js":"..\/..\/..\/..\/..\/extensions\/RowReorder\/js","resolve":true},"scroller":{"css":"..\/..\/..\/..\/..\/extensions\/Scroller\/css","js":"..\/..\/..\/..\/..\/extensions\/Scroller\/js","resolve":true},"select":{"css":"..\/..\/..\/..\/..\/extensions\/Select\/css","js":"..\/..\/..\/..\/..\/extensions\/Select\/js","resolve":true},"searchbuilder":{"css":"..\/..\/..\/..\/..\/extensions\/SearchBuilder\/css","js":"..\/..\/..\/..\/..\/extensions\/SearchBuilder\/js","resolve":true},"searchpanes":{"css":"..\/..\/..\/..\/..\/extensions\/SearchPanes\/css","js":"..\/..\/..\/..\/..\/extensions\/SearchPanes\/js","resolve":true},"staterestore":{"css":"..\/..\/..\/..\/..\/extensions\/StateRestore\/css","js":"..\/..\/..\/..\/..\/extensions\/StateRestore\/js","resolve":true},"datetime":{"css":"..\/..\/..\/..\/..\/extensions\/DateTime\/css\/dataTables.dateTime.css","js":"..\/..\/..\/..\/..\/extensions\/DateTime\/js\/dataTables.dateTime.js"},"bootstrap":{"css":"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.7\/css\/bootstrap.min.css","js":"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.7\/js\/bootstrap.min.js"},"bootstrap4":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/4.5.2\/css\/bootstrap.css","js":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/popper.js\/1.14.3\/umd\/popper.min.js|https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/4.5.2\/js\/bootstrap.min.js"},"bootstrap5":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/5.3.0\/css\/bootstrap.min.css","js":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/5.3.0\/js\/bootstrap.bundle.min.js"},"bulma":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/bulma\/0.9.3\/css\/bulma.min.css"},"foundation":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/foundation\/6.4.3\/css\/foundation.min.css","js":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/foundation\/6.4.3\/js\/foundation.min.js"},"jqueryui":{"css":"https:\/\/code.jquery.com\/ui\/1.13.2\/themes\/base\/jquery-ui.css","js":"https:\/\/code.jquery.com\/ui\/1.13.2\/jquery-ui.js"},"material":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/material-components-web\/14.0.0\/material-components-web.min.css","js":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/material-components-web\/14.0.0\/material-components-web.min.js"},"semanticui":{"css":"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/fomantic-ui\/2.9.2\/semantic.min.css","js":"https:\/\/cdnjs.c
|
||
|
jquery: function () {
|
||
|
|
||
|
|
||
|
|
||
|
$('#example').DataTable({
|
||
|
ajax: '../data/2500.txt',
|
||
|
keys: true,
|
||
|
layout: {
|
||
|
top2Start: 'searchPanes',
|
||
|
top1Start: 'searchBuilder',
|
||
|
topStart: {
|
||
|
buttons: [
|
||
|
{
|
||
|
extend: 'createState',
|
||
|
config: {
|
||
|
creationModal: true,
|
||
|
toggle: {
|
||
|
length: true,
|
||
|
order: true,
|
||
|
paging: true,
|
||
|
scroller: true,
|
||
|
search: true,
|
||
|
searchBuilder: true,
|
||
|
searchPanes: true,
|
||
|
select: true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
'savedStates'
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
rowId: 0,
|
||
|
scrollY: 200,
|
||
|
scrollCollapse: true,
|
||
|
scroller: true,
|
||
|
select: true
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
},
|
||
|
vanilla: function () {
|
||
|
|
||
|
|
||
|
|
||
|
$('#example').DataTable({
|
||
|
ajax: '../data/2500.txt',
|
||
|
keys: true,
|
||
|
layout: {
|
||
|
top2Start: 'searchPanes',
|
||
|
top1Start: 'searchBuilder',
|
||
|
topStart: {
|
||
|
buttons: [
|
||
|
{
|
||
|
extend: 'createState',
|
||
|
config: {
|
||
|
creationModal: true,
|
||
|
toggle: {
|
||
|
length: true,
|
||
|
order: true,
|
||
|
paging: true,
|
||
|
scroller: true,
|
||
|
search: true,
|
||
|
searchBuilder: true,
|
||
|
searchPanes: true,
|
||
|
select: true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
'savedStates'
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
rowId: 0,
|
||
|
scrollY: 200,
|
||
|
scrollCollapse: true,
|
||
|
scroller: true,
|
||
|
select: true
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
});
|
||
|
</script>
|
||
|
</head>
|
||
|
<body class="dt-example">
|
||
|
<div class="container">
|
||
|
<section>
|
||
|
<h1>StateRestore example <span>Creation Modal with Toggle</span></h1>
|
||
|
<div class="info">
|
||
|
<p>This example shows how the <code>toggle</code> option of StateRestore (<a href="//datatables.net/reference/type/stateRestoreConfig"><code class="type" title=
|
||
|
"Javascript parameter type">stateRestoreConfig</code></a>) can be used to decide what elements of DataTables should save their state when creating a new state.
|
||
|
This example shows all of the options that are available with the <code>toggle</code> option, apart from the column specific options. They are in a <a href=
|
||
|
"/extensions/StateRestore/examples/customisation/columns.html">separate example</a>.</p>
|
||
|
<p>This example includes all of the extensions that have a state saving element built into them. These are...</p>
|
||
|
<ul class="markdown">
|
||
|
<li>SearchBuilder</li>
|
||
|
<li>SearchPanes</li>
|
||
|
<li>Scroller</li>
|
||
|
<li>Select</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="demo-html">
|
||
|
<table id="example" class="display nowrap" style="width:100%">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>ID</th>
|
||
|
<th>First name</th>
|
||
|
<th>Last name</th>
|
||
|
<th>ZIP / Post code</th>
|
||
|
<th>Country</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
</table>
|
||
|
</div>
|
||
|
<ul class="dt-tabs">
|
||
|
<li class="active">Javascript</li>
|
||
|
<li>HTML</li>
|
||
|
<li>CSS</li>
|
||
|
<li>Ajax</li>
|
||
|
<li>Server-side script</li>
|
||
|
</ul>
|
||
|
<div class="dt-tabs">
|
||
|
<div class="js">
|
||
|
<p>The Javascript shown below is used to initialise the table shown in this example:</p>
|
||
|
<div id="js-jquery">
|
||
|
<code class="multiline language-js">$('#example').DataTable({
|
||
|
ajax: '../data/2500.txt',
|
||
|
keys: true,
|
||
|
layout: {
|
||
|
top2Start: 'searchPanes',
|
||
|
top1Start: 'searchBuilder',
|
||
|
topStart: {
|
||
|
buttons: [
|
||
|
{
|
||
|
extend: 'createState',
|
||
|
config: {
|
||
|
creationModal: true,
|
||
|
toggle: {
|
||
|
length: true,
|
||
|
order: true,
|
||
|
paging: true,
|
||
|
scroller: true,
|
||
|
search: true,
|
||
|
searchBuilder: true,
|
||
|
searchPanes: true,
|
||
|
select: true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
'savedStates'
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
rowId: 0,
|
||
|
scrollY: 200,
|
||
|
scrollCollapse: true,
|
||
|
scroller: true,
|
||
|
select: true
|
||
|
});</code>
|
||
|
</div>
|
||
|
<div id="js-vanilla">
|
||
|
<code class="multiline language-js">$('#example').DataTable({
|
||
|
ajax: '../data/2500.txt',
|
||
|
keys: true,
|
||
|
layout: {
|
||
|
top2Start: 'searchPanes',
|
||
|
top1Start: 'searchBuilder',
|
||
|
topStart: {
|
||
|
buttons: [
|
||
|
{
|
||
|
extend: 'createState',
|
||
|
config: {
|
||
|
creationModal: true,
|
||
|
toggle: {
|
||
|
length: true,
|
||
|
order: true,
|
||
|
paging: true,
|
||
|
scroller: true,
|
||
|
search: true,
|
||
|
searchBuilder: true,
|
||
|
searchPanes: true,
|
||
|
select: true
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
'savedStates'
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
rowId: 0,
|
||
|
scrollY: 200,
|
||
|
scrollCollapse: true,
|
||
|
scroller: true,
|
||
|
select: true
|
||
|
});</code>
|
||
|
</div>
|
||
|
<p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
|
||
|
<ul id="js-lib-files"></ul>
|
||
|
</div>
|
||
|
<div class="table">
|
||
|
<p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
|
||
|
</div>
|
||
|
<div class="css">
|
||
|
<div>
|
||
|
<p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
|
||
|
additional CSS used is shown below:</p><code class="multiline language-css"></code>
|
||
|
</div>
|
||
|
<p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
|
||
|
<ul id="css-lib-files"></ul>
|
||
|
</div>
|
||
|
<div class="ajax">
|
||
|
<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
|
||
|
loaded.</p>
|
||
|
</div>
|
||
|
<div class="php">
|
||
|
<p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
|
||
|
processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
|
||
|
documentation</a>.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</section>
|
||
|
</div>
|
||
|
<section>
|
||
|
<div class="footer">
|
||
|
<div class="gradient"></div>
|
||
|
<div class="liner">
|
||
|
<h2>Other examples</h2>
|
||
|
<div class="toc">
|
||
|
<div class="toc-group">
|
||
|
<h3><a href="../initialisation/index.html">Initialisation and options</a></h3>
|
||
|
<ul class="toc">
|
||
|
<li>
|
||
|
<a href="../initialisation/simple.html">Basic StateRestore Example</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/alternative.html">Alternative UI</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/api.html">Basic StateRestore Example - API</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/customSplit.html">Custom Split Buttons</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/removeAll.html">Remove All Button</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/ajax.html">Ajax Loading and Saving</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/ajaxFunction.html">Ajax Function</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/predefined.html">Predefined States</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/predefinedAjax.html">Predefined States from Ajax</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/predefinedAjaxNoSave.html">Predefined States - No Save, Remove, Rename or Create</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/noCreation.html">No state creation</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/noRemoval.html">No state remove</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/noRenaming.html">No state renaming</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/noSaving.html">No state saving</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../initialisation/noButtons.html">No Buttons</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="toc-group">
|
||
|
<h3><a href="./index.html">Customisation</a></h3>
|
||
|
<ul class="toc active">
|
||
|
<li>
|
||
|
<a href="./activeLabel.html">Label to Display Active States</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./creationModal.html">Creation Modal</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./customStateData.html">Custom State Data</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./columns.html">Creation Modal with Toggle for Columns</a>
|
||
|
</li>
|
||
|
<li class="active">
|
||
|
<a href="./creationModalToggle.html">Creation Modal with Toggle</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./i18n.html">StateRestore Language Options</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./stateCount.html">Custom Button Text</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noColumnSearch.html">Don't save column searches</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./childRows.html">Child Rows</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noColumnVisibility.html">Don't save column visibility</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noOrder.html">Don't save ordering</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noLength.html">Don't save page length</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noPaging.html">Don't save paging</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noScroller.html">Don't save scroller</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noSearch.html">Don't save search</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noSearchBuilder.html">Don't save SearchBuilder</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noSearchPanes.html">Don't save SearchPanes</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="./noSelect.html">Don't save Selections</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="toc-group">
|
||
|
<h3><a href="../integration/index.html">Integration with other DataTables extensions</a></h3>
|
||
|
<ul class="toc">
|
||
|
<li>
|
||
|
<a href="../integration/preDefinedSearchPanes.html">Predefined SearchPanes State</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../integration/scroller.html">Scroller Integration</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../integration/searchBuilder.html">SearchBuilder Integration</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../integration/searchPanes.html">SearchPanes Integration</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../integration/select.html">Select Integration</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../integration/colReorder.html">ColReorder Integration</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="toc-group">
|
||
|
<h3><a href="../styling/index.html">Styling</a></h3>
|
||
|
<ul class="toc">
|
||
|
<li>
|
||
|
<a href="../styling/bootstrap3.html">Bootstrap 3</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/bootstrap4.html">Bootstrap 4</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/bootstrap5.html">Bootstrap 5</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/bulma.html">Bulma</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/foundation.html">Foundation</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/jqueryui.html">JQuery UI</a>
|
||
|
</li>
|
||
|
<li>
|
||
|
<a href="../styling/semanticui.html">Fomantic-UI (formally Semantic-UI) styling</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="epilogue">
|
||
|
<p>Please refer to the <a href="https://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
|
||
|
Additionally, there are a wide range of <a href="https://www.datatables.net/extensions">extensions</a> and <a href=
|
||
|
"https://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
|
||
|
<p class="copyright">DataTables designed and created by <a href="https://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2024<br>
|
||
|
DataTables is licensed under the <a href="https://www.datatables.net/mit">MIT license</a>.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</section>
|
||
|
</body>
|
||
|
</html>
|