1

While it seems I can remove some rows, is it possible to skip rendering of some rows based on some filtering logic?

e.g. don't render a row where model.get('someProp') == 'X'

gxc
  • 4,946
  • 6
  • 37
  • 55

1 Answers1

1

I guess css-solution, e.g. display:none;, is ok? Hence, you may play with classNames by just extending the row model you use (backbone native functionality):

...
options.row = Backgrid.Row.extend({
  className: function() {
    return this.model.get('property') == 1 ? 'renderme' : 'hideme';
  }
});
var grid = new Backgrid.Grid(options);

And then apply whatever styles you want to those classes. Of course, you could override the render-method of Backgrid.Row by extending it and check the models property there, but you would end up overriding Backgrid.Body as well.

I find using css class names being more flexible multi-purpose solution.

pekkast
  • 309
  • 2
  • 4
  • Not ideal to render something that won't be displayed. But yeah, that 's one way of doing it, thanks. – gxc Apr 15 '14 at 00:17