Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

How to prevent multi-row selection? #657

Open
millerbryan opened this issue Oct 13, 2016 · 3 comments
Open

How to prevent multi-row selection? #657

millerbryan opened this issue Oct 13, 2016 · 3 comments

Comments

@millerbryan
Copy link

I am new to backgrid and using it in a form to allow the user to select a row (via a checkbox) and then click "Submit". I cannot figure out how to configure my grid checkboxes to behave like "radio buttons" in that only one row can be selected at a time. Is this something backgrid natively supports or do I need to write a handler to "unselect" previously selected rows?

[disclaimer: I paid my dues to Google and Stackoverflow before posting here...]

@millerbryan
Copy link
Author

millerbryan commented Oct 14, 2016

Initial thoughts on a programmatic solution are as follows:

  1. Add an backgrid:select event handler to the model which catches a row being selected.

  2. The event handler calls a function which calls grid.getSelectedModels() and toggles the currently selected row/model to FALSE.

@millerbryan
Copy link
Author

Either everyone is stumped too or this is a FAQ and I should feel foolish.

@millerbryan
Copy link
Author

I added an event listener to my view:

this.Collection.on('backgrid:selected', function(model, selected) {
// Do stuff here
});

and I am able to get the contents of the selected model. What I need to get is the row ID of the selected row.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant