MCPcopy Create free account
hub / github.com/breck7/scroll / _fnFilter

Function _fnFilter

external/.datatables.js:4138–4167  ·  view source on GitHub ↗

* Filter the data table based on user input and draw the table

(searchRows, settings, input, options, column)

Source from the content-addressed store, hash-verified

4136 * Filter the data table based on user input and draw the table
4137 */
4138 function _fnFilter(searchRows, settings, input, options, column) {
4139 if (input === "") {
4140 return
4141 }
4142
4143 var i = 0
4144 var matched = []
4145
4146 // Search term can be a function, regex or string - if a string we apply our
4147 // smart filtering regex (assuming the options require that)
4148 var searchFunc = typeof input === "function" ? input : null
4149 var rpSearch = input instanceof RegExp ? input : searchFunc ? null : _fnFilterCreateSearch(input, options)
4150
4151 // Then for each row, does the test pass. If not, lop the row from the array
4152 for (i = 0; i < searchRows.length; i++) {
4153 var row = settings.aoData[searchRows[i]]
4154 var data = column === undefined ? row._sFilterRow : row._aFilterData[column]
4155
4156 if ((searchFunc && searchFunc(data, row._aData, searchRows[i], column)) || (rpSearch && rpSearch.test(data))) {
4157 matched.push(searchRows[i])
4158 }
4159 }
4160
4161 // Mutate the searchRows array
4162 searchRows.length = matched.length
4163
4164 for (i = 0; i < matched.length; i++) {
4165 searchRows[i] = matched[i]
4166 }
4167 }
4168
4169 /**
4170 * Build a regular expression object suitable for searching a table

Callers 1

_fnFilterCompleteFunction · 0.85

Calls 1

_fnFilterCreateSearchFunction · 0.85

Tested by

no test coverage detected