Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

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
Description

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 function

and change it to (adding the comma and a new line):

onSubmit: false, // using a custom populate function
multiselect: false  // allow selection of multiple elements

2) 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: true

parameter 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();
        }
    }
)