Skip to content

Commit

Permalink
Merge pull request #149 from StrykeSlammerII/patch-2
Browse files Browse the repository at this point in the history
Additional usage notes (and working code sample) for `addParams`
  • Loading branch information
lcharette authored Nov 1, 2024
2 parents 6e39c60 + ef2a173 commit 36cabf6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pages/15.client-side-code/04.components/02.tables/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,19 @@ An object containing tablesorter's [configuration options](https://mottie.github

An object containing any additional key-value pairs that you want appended to the AJAX requests made by the table. Useful when implementing, for example, site-wide filters or using data sources that require additional context.

When sending an AJAX request to a Sprunje, there are some hoops to jump through:
1. Remember that sprunjes only accept [certain parameters](/database/data-sprunjing#sprunje-parameters). If, for instance, you want to filter by "UserID" that's set outside of the table, you'll need to pass `filters[UserID]` in the AJAX request rather than simply `UserID`.
2. Additionally, sprunjes only accept [whitelisted fields](/database/data-sprunjing#sorts-and-filters), so you'll need to ensure that `UserID` is in the appropriate array in the sprunje--in this case, `$filterable`.
3. Optional: Unless you're hardcoding the parameter value, you may need to [export it to JS](/client-side-code/exporting-variables).

In this Javascript sample, we've already asked the user for a Genus name and exported it to the variable `page.owl.genus`.
```javascript
$("#myUserTable").ufTable({
dataUrl: site.uri.public + "/api/owls",
addParams: {"filters[species]" : page.owl.genus}
});
```

### filterAllField

The special filter name that should be sent in AJAX requests when a global search (as opposed to column-specific searches) is performed. Defaults to `_all`.
Expand Down

0 comments on commit 36cabf6

Please sign in to comment.