I'm using Backgrid and Pagination with Backbone and I'm using fetch to filter a collection, which in turn updates the Backgrid table and the Paginations controls.
filterFunction: function (query) {
_.each(query, function (q) {
if(List.grid.collection.queryParams.hasOwnProperty(q.key)) {
var firstValue = List.grid.collection.queryParams[q.key]
List.grid.collection.queryParams[q.key] = firstValue + ',' + q.value
} else {
List.grid.collection.queryParams[q.key] = q.value
}
})
List.grid.collection.fetch(
{
'reset': true
})
}
which works well and once the collection has been filtered I might for example have a collection that is 6 long instead of 60. My problem arises when I want to unfilter the collection and go back to the original 60 long collection. I did think I could just call the original listAllFunction - but that function redraws the backgrid and the pagination controls to the page. I think a much nicer way would be to write some sort of function that overrides the fetch to ask for ALL results. So something like:
List.grid.collection.**fetchALL** (
{
'reset' : true,
'url': // tell it to go and get ALL the results?
}
)
Is this possible? Or any suggestions on an approach I should take?