File: columns%28%29.search%28%29.xml

package info (click to toggle)
datatables.js 1.11.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,848 kB
  • sloc: javascript: 65,075; xml: 10,712; php: 4,741; sh: 544; makefile: 18
file content (111 lines) | stat: -rw-r--r-- 5,085 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="columns">
	<name>columns().search()</name>
	<summary>Search for data in the selected columns.</summary>
	<since>1.10</since>

	<type type="function">
		<signature>columns().search()</signature>
		<description>Get the currently applied column search.</description>
		<returns type="DataTables.Api">Api instance with the applied search terms for the selected columns in the result set.</returns>
	</type>
	<type type="function">
		<signature>columns().search( input [, regex[ , smart[ , caseInsen ]]] )</signature>
		<description>Set the search term for the columns from the selector. Note this doesn't actually perform the search, but rather queues it up - use `dt-api draw()` to perform the search and display the result.</description>
		<parameter type="string" name="input">
			Search string to apply to the selected columns.
		</parameter>
		<parameter type="boolean" name="regex" default="false">
			Treat as a regular expression (`true`) or not (default, `false`).
		</parameter>
		<parameter type="boolean" name="smart" default="true">
			Perform smart search (default, `true`) or not (`false`). Please refer to `dt-api search()` for a full description of smart filtering.

			Note that to perform a smart search, DataTables uses regular expressions, so if enable regular expressions using the second parameter to this method, you will likely want to disable smart searching as the two regular expressions might otherwise conflict and cause unexpected results.
		</parameter>
		<parameter type="boolean" name="caseInsen" default="true">
			Do case-insensitive matching (default, `true`) or not (`false`).
		</parameter>
		<returns type="DataTables.Api">DataTables API instance</returns>
	</type>

	<description>
		While `dt-api search()` provides the ability to search globally across the table, this method, and its singular counterpart, provide the ability to search for data on specific columns.

		DataTables does not have any column search controls built-in as there are so many different ways that column specific data could be searched, but this method makes adding custom column search controls super easy. The examples below show how it may be used.

		DataTables has a built in search algorithm referred to as "smart" searching and is designed to make searching the table data, easy to use for the end user. The smart search is performed using a regular expression and thus must be considered if you are using a regular expression search (second parameter of this method). For a full description of smart searching in DataTables, please refer to the documentation for `dt-api search()`.

		Note that this search ability in DataTables is actually technically a filter since it is subtractive. However, we term is a search to avoid naming overlap with the `dt-api filter()` helper method.

		Please be aware that this method sets the search to apply to the table only - it does not actually perform the search. In order to have the search performed and the result shown, use the `dt-api draw()` method, which can be called simply as a chained method of the `dt-api columns().search()` method's returned object - for example `table.columns( [0, 1] ).search( 'Fred' ).draw();`. This is to provide the ability to queue multiple changes before performing a draw.
	</description>

	<example title="Apply a search to multiple columns"><![CDATA[
var table = $('#example').DataTable();

table
	.columns( '.status' )
	.search( 'Important' )
	.draw();
]]></example>

	<example title="Build a text `-tag input` search for each column. Note that this example performs partial word matching and smart searching."><![CDATA[
// Setup - add a text input to each footer cell
$('#example tfoot th').each( function () {
	var title = $('#example thead th').eq( $(this).index() ).text();
	$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
} );

// DataTable
var table = $('#example').DataTable();

// Apply the filter
table.columns().every( function () {
	var column = this;

	$( 'input', this.footer() ).on( 'keyup change', function () {
		column
			.search( this.value )
			.draw();
	} );
} );

]]></example>

	<example title="Build a search for each column with a `select-filter` class."><![CDATA[
var table = $('#example').DataTable();

table.columns( '.select-filter' ).every( function () {
	var that = this;

	// Create the select list and search operation
	var select = $('<select />')
		.appendTo(
			this.footer()
		)
		.on( 'change', function () {
			that
				.search( $(this).val() )
				.draw();
		} );

	// Get the search data for the first column and add to the select list
	this
		.cache( 'search' )
		.sort()
		.unique()
		.each( function ( d ) {
			select.append( $('<option value="'+d+'">'+d+'</option>') );
		} );
} );

]]></example>


	<related type="option">searching</related>
	<related type="option">columns.searchable</related>
	<related type="api">search()</related>
	<related type="api">column().search()</related>
	<related type="api">$.fn.dataTable.util.escapeRegex()</related>
</dt-api>