0

I'm using the Backgrid filter extension http://backgridjs.com/ref/extensions/filter.html and I'm wondering how I can

  1. Set the search element to a checkbox instead of a search box
  2. Chain a series of query parameters ala ?q='djfsl'&q2='jdfskf'

So far I have this:

 var customFilter = Backgrid.Extension.ServerSideFilter.extend({
     selectOptions: [{
        label: 'Review', value: 0
      }],
     // override the makeMatcher function to turn the query into an int
     makeMatcher: function (query) {
        var intQuery = parseInt(query, 10)
        return intQuery
       }
    })

var serverSideFilter = new customFilter({
    collection: recipes,
    placeholder: 'Search term',
    name: ['tags']
 })

recipesListLayout.recipesRegion.show(grid)
// this renders a SearchBox by default - want to know how to create checkboxes instead?
recipesListLayout.panelRegion.$el.append(serverSideFilter.render().el)

However, what I want to achieve is something more along the lines of this: http://www.codegur.net/20767244/add-backgrid-filter-for-each-column

Or more precisely this:

enter image description here

where multiple checkboxes can be selected and the query created would be something like: ?review=0&featured=1

With the code I have at the moment I seem to be only able to set one query parameter which looks like ?tags=0 where tags has been set as the name in my customFilter.

Linda Keating
  • 2,215
  • 7
  • 31
  • 63
  • 1
    I would go straight to the collection and so something like this: http://jsfiddle.net/euwm3LLt/ note that the params would be sent to your collection at the moment in time. Post more code if you want more integration. – Javier Buzzi Nov 05 '15 at 15:28
  • I agree with @JavierBuzzi. As far as I remember backgrid's filtering system (currently) is not as flexible as I would except. Actually I had the same need a few months ago and I indeed created my own filters on the collection itself, as javier suggested, and it worked great. – MorKadosh Nov 06 '15 at 07:47

0 Answers0