cloudflarearchive / backgrid-select-all

Select-all extension for Backgrid.js
http://backgridjs.com
MIT License
12 stars 31 forks source link

Added ability to get list of ids and clear the selection. #6

Closed yubik9 closed 10 years ago

yubik9 commented 10 years ago

It is useful to allow people clear selection and get selected items ids.

Not all the models will be returned if they are using pageable extension.

wyuenho commented 10 years ago

Grid.getSelectedIds is effectively the same as:

_.map(grid.getSelectedModels(), function (model) { return model.id; } );

Grid.clearSelection can be greatly simplified to:

_.map(grid.getSelectedModels(), function (model) { model.trigger("backgrid:select", model, false) } );

Your implementation is way too complicated

yubik9 commented 10 years ago

It won't work with pageable extension as there is no fullCollection available.

Do you have any idea how to deal with this situation?

On Friday, October 11, 2013, Jimmy Yuen Ho Wong wrote:

Grid.getSelectedIds is effectively the same as:

_.map(grid.getSelectedModels(), function (model) { return model.id; } );

Grid.clearSelection can be greatly simplified to:

_.map(grid.getSelectedModels(), function (model) { model.trigger("backgrid:select", model, false) } );

Your implementation is way too complicated

— Reply to this email directly or view it on GitHubhttps://github.com/wyuenho/backgrid-select-all/pull/6#issuecomment-26112043 .

bruno-c commented 10 years ago

Since we're simplifying

getSelectedIds

_.pluck(grid.getSelectedModels(), 'id');

@fanminjian, do you mean that you want to persist the selection across many pages?

wyuenho commented 10 years ago

See https://github.com/wyuenho/backgrid-select-all/pull/4