Skip to content

Commit

Permalink
Added custom search function to List API doc - closes javve#678
Browse files Browse the repository at this point in the history
  • Loading branch information
sheffieldnick committed Apr 2, 2020
1 parent cf4b090 commit 805e1bb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ <h3><a name="methods" class="anchor" href="#methods"></a>Methods</h3>

</li>
<li>
<p><strong><a name="search" class="achor" href="#search"></a>search(searchString, columns)</strong><br>
<p><strong><a name="search" class="achor" href="#search"></a>search(searchString, columns, searchFunction)</strong><br>
Searches the list</p>

<pre><code class="javascript">itemsInList = [
Expand All @@ -285,7 +285,20 @@ <h3><a name="methods" class="anchor" href="#methods"></a>Methods</h3>

listObj.search(); // Show all items in list

listObj.search('Jonny', ['name']); // Only search in the 'name' column</code></pre>
listObj.search('Jonny', ['name']); // Only search in the 'name' column

listObj.search('Jonny', searchFunction); // Custom search for Jonny

listObj.search('Jonny', ['name'], searchFunction); // Custom search in the 'name' column</code></pre>
<p>The optional <code>searchFunction</code> should be of the form:</p>

<pre><code class="javascript">function searchFunction(searchString, columns) {
for (var k = 0, kl = listObj.items.length; k &lt; kl; k++) {
listObj.items[k].found = false;
// Insert your custom search logic here, set found = true

}
};</code></pre>

</li>
<li>
Expand Down

0 comments on commit 805e1bb

Please sign in to comment.