Genre Endpoint custom_filter kwargs

Each button swaps the Ajax endpoint. The server applies a MongoDB query via keyword arguments — DataTables(db, 'records', data, genre='Jazz'). Notice recordsTotal changes — this is a true server-side filter, not a client search.

Fixed Searches search.fixed / column().search.fixed

Named fixed searches stack as AND conditions. Each has a unique name so they don't overwrite each other. Toggle multiple to combine. With serverSide: true, these are sent in the request and processed by mongo-datatables.

Active:
ArtistTitleLabel YearGenreFormatRating
How It Works
Fixed Searches (client → server)

Fixed searches are injected manually into the Ajax data callback as columns[i].searchFixed (global) or searchFixed (table-level) — a dict keyed by name. mongo-datatables reads both formats and applies each term as an additional $match condition.

// Client: inject via Ajax data callback
ajax: { data: function(d) {
    d.columns[7].searchFixed = {
        essential: active ? '4|' : undefined
    };
}}

// Server reads columns[7].searchFixed:
// { "essential": "4|" }
// → { "rating": { "$gte": 4 } }
Custom Filters (server-side)

Genre buttons swap the Ajax URL. Each endpoint passes keyword arguments to the DataTables constructor — these become a $match stage prepended to every pipeline. Because the filter is applied server-side, recordsTotal reflects only the filtered subset.

# /api/records/genre/jazz route:
DataTables(db, 'records', data,
           data_fields=FIELDS,
           genre='Jazz')

# Equivalent to prepending:
# { "$match": { "genre": "Jazz" } }