dev: Update to use the new search.return initialisation option

Jira Issue DD-2073
pull/527/head
SandyDatatables 3 years ago
parent dfdb13d413
commit 3195490f51

@ -199,10 +199,11 @@
$(document).on('init.dt', function(e, settings) {
var api = new $.fn.dataTable.Api(settings);
var initial = api.init().fuzzySearch;
var initial = api.init();
var initialFuzzy = initial.fuzzySearch;
// If this is not set then fuzzy searching is not enabled on the table so return.
if(!initial) {
if(!initialFuzzy) {
return;
}
@ -232,7 +233,7 @@
// Only going to set the toggle if it is enabled
var toggle, tooltip, exact, fuzzy, label;
if(initial.toggleSmart) {
if(initialFuzzy.toggleSmart) {
toggle =$('<button class="toggleSearch">Abc</button>')
.insertAfter(input)
.css({
@ -300,7 +301,7 @@
// The function that we want to run on search
var triggerSearchFunction = function(event){
// If the search is only to be triggered on return wait for that
if ((event.type === 'input' && !initial.returnSearch) || event.key === "Enter") {
if ((event.type === 'input' && !initial.search.return) || event.key === "Enter") {
// If the toggle is set and isn't checkd then perform a normal search
if(toggle && !toggle.attr('blurred')) {
api.rows().iterator('row', function(settings, rowIdx) {
@ -324,7 +325,7 @@
// For each row call the fuzzy search function to get result
api.rows().iterator('row', function(settings, rowIdx) {
settings.aoData[rowIdx]._fuzzySearch = fuzzySearch(fuzzySearchVal, settings.aoData[rowIdx]._aFilterData, initial)
settings.aoData[rowIdx]._fuzzySearch = fuzzySearch(fuzzySearchVal, settings.aoData[rowIdx]._aFilterData, initialFuzzy)
});
fromPlugin = true;
@ -352,7 +353,7 @@
// For each row call the fuzzy search function to get result
api.rows().iterator('row', function(settings, rowIdx) {
settings.aoData[rowIdx]._fuzzySearch = fuzzySearch(fuzzySearchVal, settings.aoData[rowIdx]._aFilterData, initial)
settings.aoData[rowIdx]._fuzzySearch = fuzzySearch(fuzzySearchVal, settings.aoData[rowIdx]._aFilterData, initialFuzzy)
});
// triggerSearchFunction({key: 'Enter'});
return this;

@ -71,7 +71,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to DataTables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -79,7 +79,6 @@ $(document).ready(function() {
to the user, or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
</div>
<div class="demo-html">

@ -73,7 +73,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to Datatables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -81,7 +81,6 @@ $(document).ready(function() {
to the user. or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
<p>This example demonstrates the use of the <code>fuzzySearch.rankColumn</code> initialisation option. The default value for this option is undefined which will lead to the
similarity not being displayed in any column. In this example <code>fuzzySearch.rankColumn</code> is set to <code>6</code> which is the column on the far right of
@ -631,13 +630,11 @@ $(document).ready(function() {
</table>
</div>
<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
$(document).ready(function() {
var table = $('#example').DataTable({
fuzzySearch: {
rankColumn: 6
}
});
} );
} );</code>
</div>
</section>

@ -55,9 +55,8 @@
$(document).ready(function() {
var table = $('#example').DataTable({
fuzzySearch: {
returnSearch: true
}
fuzzySearch: true,
search:{return: true}
});
} );
@ -73,7 +72,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to Datatables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -81,10 +80,9 @@ $(document).ready(function() {
to the user. or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
<p>This example demonstrates the use of the <code>fuzzySearch.returnSearch</code> initialisation option. The default value for this option is undefined which lead to the search
results being updated on every keypress. In this example <code>fuzzySearch.returnSearch</code> is set to <code>true</code>, meaning that the search results displayed within the table will
<p>This example demonstrates how fuzzy searching can make use of the <code>search.return</code> initialisation option which is new in DataTables version 1.11. The default value for this option is false which lead to the search
results being updated on every keypress. In this example <code>search.return</code> is set to <code>true</code>, meaning that the search results displayed within the table will
only be updated when the enter key is pressed.</p>
</div>
<div class="demo-html">
@ -570,13 +568,10 @@ $(document).ready(function() {
</table>
</div>
<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
$(document).ready(function() {
var table = $('#example').DataTable({
fuzzySearch: {
returnSearch: true
}
fuzzySearch: true,
search:{return: true}
});
} );
} );</code>
</div>
</section>

@ -75,7 +75,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to Datatables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -83,7 +83,6 @@ $(document).ready(function() {
to the user. or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
<p>This example shows how fuzzySearch integrates with <code>stateSave</code>. The search mode, the value within the search box and the search results are restored
as they were on reload. To display all of the <code>stateSave</code> functionality, <code>fuzzySearch.toggleSmart</code> and <code>fuzzySearch.rankColumn</code>
@ -631,7 +630,6 @@ $(document).ready(function() {
</table>
</div>
<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
$(document).ready(function() {
var table = $('#example').DataTable({
fuzzySearch: {
rankColumn: 6,
@ -639,7 +637,6 @@ $(document).ready(function() {
},
stateSave: true
});
} );
} );</code>
</div>
</section>

@ -74,7 +74,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to Datatables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -82,7 +82,6 @@ $(document).ready(function() {
to the user. or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
<p>This example demonstrates the use of the <code>fuzzySearch.threshold</code> initialisation option. The default value for this option is 0.5. This value is used to
compare against the Damerau-Levenshtein similarity metric which is calculated by dividing the number of changes needed to make the words the same, by the length of

@ -74,7 +74,7 @@ $(document).ready(function() {
term. This allows spelling mistakes and typos to be accounted for. It also allows small changes in dialect not to affect search results. A commonly used example is
for surname searching. "Smith" and "Smythe" are pronounced the same way, but using conventional searching typing "Smith" would not return "Smythe".</p>
<p>This plug-in adds fuzzy search functionality to Datatables. It does this through a combination of exact matching and the <a href=
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are four initialisation options that are associated with this
"https://github.com/tad-lispy/node-damerau-levenshtein">Damerau-Levenshtein algorithm</a>. There are three initialisation options that are associated with this
plugin.</p>
<ul class="markdown">
<li><code>fuzzySearch.toggleSmart</code> allows the searching to be changed from exact matching to fuzzy searching.</li>
@ -82,7 +82,6 @@ $(document).ready(function() {
to the user. or to hide the column and order based on it - as a search engine would.</li>
<li><code>fuzzySearch.threshold</code> allows the value of similarity that is required from the Damerau-Levenshtein function to display the row to be
changed.</li>
<li><code>fuzzySearch.returnSearch</code> allows the option for searching to only occur when the enter key is pressed.</li>
</ul>
<p>This example demonstrates the use of the <code>fuzzySearch.toggleSmart</code> initialisation option. The default value for this option is undefined which leads
to fuzzy searching being used all the time if the <code>fuzzySearch</code> option is declared in the initialisation options. In this example <code>fuzzySearch.toggleSmart</code>

Loading…
Cancel
Save