Skip to content

Commit 36cabf6

Browse files
authored
Merge pull request #149 from StrykeSlammerII/patch-2
Additional usage notes (and working code sample) for `addParams`
2 parents 6e39c60 + ef2a173 commit 36cabf6

File tree

1 file changed

+13
-0
lines changed
  • pages/15.client-side-code/04.components/02.tables

1 file changed

+13
-0
lines changed

pages/15.client-side-code/04.components/02.tables/docs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,19 @@ An object containing tablesorter's [configuration options](https://mottie.github
348348

349349
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.
350350

351+
When sending an AJAX request to a Sprunje, there are some hoops to jump through:
352+
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`.
353+
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`.
354+
3. Optional: Unless you're hardcoding the parameter value, you may need to [export it to JS](/client-side-code/exporting-variables).
355+
356+
In this Javascript sample, we've already asked the user for a Genus name and exported it to the variable `page.owl.genus`.
357+
```javascript
358+
$("#myUserTable").ufTable({
359+
dataUrl: site.uri.public + "/api/owls",
360+
addParams: {"filters[species]" : page.owl.genus}
361+
});
362+
```
363+
351364
### filterAllField
352365

353366
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`.

0 commit comments

Comments
 (0)