[eluser]Unknown[/eluser]
Hi guys, I found flexigrid a few days ago, and I think it's great. I had been wondering if it were possible to make it select only 1 row at a time, and I saw that many other people were asking for this functionality. So, I sat down this afternoon and worked out a solution that seems to work (IE7/8, and FF2).
First, add a new property to the
Code:
p = $.extend({
selOne: true,
...
array (line 19).
Then, I added this method:
Code:
selNone: function() {
//go through each row in the table, and make sure it is not selected
$('tbody tr',this.bDiv).each(
function() {
$(this).removeClass('trSelected');
}
);
return true;
},
to line 95 right before the fixHeight method.
Lastly, inside the `addRowProp` method, there is a click handler, add:
Code:
if (p.selOne)
{
if (!$(this).hasClass('trSelected'))
{
g.selNone();
$(this).toggleClass('trSelected');
} else {
g.selNone();
}
} else {
$(this).toggleClass('trSelected');
}
after
Code:
var obj = (e.target || e.srcElement); if (obj.href || obj.type) return true;
(line 718)
Then, change the mousedown handler to
Code:
.mousedown(
function (e)
{
if (!p.selOne)
{
if (e.shiftKey)
{
$(this).toggleClass('trSelected');
g.multisel = true;
this.focus();
$(g.gDiv).noSelect();
}
}
}
)
(Line 727)
I think that I got all my changes on here. Try it out and tell me what you think.