cloudflarearchive / backgrid-select-all

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

Header automatically select when all rows selected #7

Closed pmaidens closed 10 years ago

pmaidens commented 10 years ago

When the user selects all the rows of the grid, the header cell will automatically update its state to selected. This keeps it consistent with the state of the grid. This is accomplished by comparing the length of the collection with the number of selected models.

Unit tests are done in a different manner than other tests in the suite. This is to ensure that they function properly. This is the only way I found to successfully test for the change.

wyuenho commented 10 years ago

Why does it matter that the header cell be selected if you manually select all the other models?

pmaidens commented 10 years ago

The header cell represents the state of all the other rows in the table. If all the rows in the table are selected, the header should accurately represent the state of the table. As it currently sits, when all the rows are manually selected, the header will remain unselected. As a result, a user can click on the header cell and no practical event occurs. However, behind the scenes, it is likely that superfluous code will be run because it will fire all the events associated with selecting each row. This creates avoidable latency that provides no benefit to the user. From my teams observations of a table in production, it is much more likely that the user wants to unselect all the rows after he has manually checked them all than wanting to reselect all the rows.