Patch to select one-and-only-one row at a time
| Project: | Flexigrid for jQuery |
| Version: | 1.0.2-beta-2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Here’s a patch to allow the selection of one-and-only-one record at a time.
1) Find line 52 of flexigrid.js, which reads:
onSubmit: false // using a custom populate functionand change it to (adding the comma and a new line):
onSubmit: false, // using a custom populate function
multiselect: false // allow selection of multiple elements2) Find line 709 which reads:
var obj = (e.target || e.srcElement); if (obj.href || obj.type) return true;and, after it, add:
if ( p.multiselect == false ) {
$(t).find("tr.trSelected:not(#" + this.id + ")").removeClass('trSelected');
}That’s it. You can still create multi-select flexigrids, by supplying the:
multiselect: trueparameter when creating one.
On a side note, I think the ideal solution for Flexigrid would be to always have the mouse click unselect all other items, while giving the option to make multiple selection using control and shift keys (if multiselect is enabled, otherwise don’t give that option at all). This is probably the behaviour most GUI users expect.

Comments
#1
To avoid multiselect using shift key you can add:
.mousedown(function (e) {
if (e.shiftKey) {
if(p.multiselect) {
$(this).toggleClass('trSelected');
g.multisel = true;
}
this.focus();
$(g.gDiv).noSelect();
}
}
)