This can only be done using JavaScript. The selected event should be used to determine the end of the selection. Then check if the previous / next row / cell has the selected class. If so, add a class to work with the appropriate border.
Look at the code, I used descriptive names.
Fiddle: http://jsfiddle.net/UxwD4/11/
CSS:
.ui-border-top { border-top: #eee; } .ui-border-right { border-right: #eee; } .ui-border-bottom { border-bottom: #eee; } .ui-border-left { border-left: #eee; }
JavaScript:
$("tbody").selectable({ filter: 'td:not(.user)', selected: function(){ $('td.ui-selectee', this).each(function(){ var cell = $(this), row = cell.parent(), cellIndex = cell.index(); cell.removeClass('ui-border-top ui-border-right ui-border-bottom ui-border-left'); if (cell.hasClass('ui-selected')) { var up = row.prev().children().eq(cellIndex).hasClass('ui-selected'), right = cell.next().hasClass('ui-selected'), down = row.next().children().eq(cellIndex).hasClass('ui-selected'), left = cell.prev().hasClass('ui-selected'); if (up) cell.addClass('ui-border-top'); if (right) cell.addClass('ui-border-right'); if (down) cell.addClass('ui-border-bottom'); if (left) cell.addClass('ui-border-left'); } }); } });
Rob w source share