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

Disable editing on a cell feature #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1>editableTableWidget<br/> <small>tiny editable jQuery Bootstrap spreadsheet</
<tr><td>Bike</td><td>330</td><td>240</td><td>1</td></tr>
<tr><td>Plane</td><td>430</td><td>540</td><td>3</td></tr>
<tr><td>Yacht</td><td>100</td><td>200</td><td>0</td></tr>
<tr><td>Segway</td><td>330</td><td>240</td><td>1</td></tr>
<tr><td class="edit-disabled">Segway <- Editing disabled</td><td>330</td><td>240</td><td>1</td></tr>
</tbody>
<tfoot><tr><th><strong>TOTAL</strong></th><th></th><th></th><th></th></tr></thead>
</table>
Expand Down Expand Up @@ -97,6 +97,11 @@ <h2>Usage</h2>
return false; // reject change
}
});
</pre>

<p>Disable editing on some cells by adding a class to them</p>
<pre class="prettyprint">
$('#table').editableTableWidget({disableClass: "edit-disabled"});
</pre>
</div>
<div class="span6" >
Expand Down
3 changes: 2 additions & 1 deletion mindmup-editabletable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $.fn.editableTableWidget = function (options) {
active,
showEditor = function (select) {
active = element.find('td:focus');
if (active.length) {
if (active.length && !active.hasClass(activeOptions.disableClass)) {
editor.val(active.text())
.removeClass('error')
.show()
Expand Down Expand Up @@ -126,6 +126,7 @@ $.fn.editableTableWidget.defaultOptions = {
cloneProperties: ['padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right',
'text-align', 'font', 'font-size', 'font-family', 'font-weight',
'border', 'border-top', 'border-bottom', 'border-left', 'border-right'],
disableClass: 'edit-disabled',
editor: $('<input>')
};