Skip to content

Commit fc61cae

Browse files
Adding some info about partial search in Readme
1 parent b8b56d3 commit fc61cae

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,21 @@ var parser = new Parser<Person>(p, context.People)
302302
```
303303
For examples using MySQL and PostgreSQL please see the test project
304304

305+
**Partial String Searches**
306+
307+
By default, the library does filtering by calling String.Contains() on a field with the search term as the argument. For those who want to match only the start or end of the field, there is a concept of start and end tokens. When these tokens are found at the start or end of a search term the library calls `String.StartsWith()` or `String.EndsWith()` respectively. If both tokens are present the default `String.Contains()` will be called. The default tokens are *\*|* for matching the beginning of the field and *|\** for matching the end of a field.
308+
309+
For example, you might want to filter by all users with a name that begins with the letter *a*. In that cases, you would allow the user to search as usual and prepend the token to the search term either in the [pre-xhr hook](https://datatables.net/reference/event/preXhr) or on the server side before the Datatable config vars are passed to the library.
310+
311+
The start and end tokens can be replaced with custom strings by using the following methods:
312+
313+
```csharp
314+
var parser = new Parser<Person>(p, context.People)
315+
.SetStartsWithToken("--")
316+
.SetEndsWithToken("++");
317+
```
318+
319+
*This feature is still experimental. As of now it is not available in the Nuget package.*
305320

306321
Installation
307322
========================

0 commit comments

Comments
 (0)