NOTE!
- This widget can not be applied to the original plugin and requires jQuery 1.7+ and a browser that supports
contenteditable
attributes (almost all modern browsers). - Note: In Internet Explorer, please wrap the cell content with a DIV or SPAN as it is not possible to make table cells directly contenteditable. Wrapping the content in the markup is much more efficient than using javascript to do it for you (especially in IE).
- Updated v2.13.2, because of the limitation in IE, if a table cell contains any DIV or SPAN immediately inside the cell, it will be targeted instead of the table cell itself and made content editable. So, if you don't care about IE support, there is no need to include the extra markup.
- In some browsers, additional CSS is needed to highlight a focused editable table cell. See the CSS block below.
- Editable widget options include (defaults in parenthesis):
editable_column
([]
)- In tablesorter core v2.14.2, this widget was updated to allow passing a range string in this option, i.e.
"0-2"
instead of[0,1,2]
. - Contains an array of columns numbers you want to have editable content (zero-based index).
contenteditable="true"
is added to cells within these columns.
- In tablesorter core v2.14.2, this widget was updated to allow passing a range string in this option, i.e.
editable_enterToAccept
(true
) - Makes the user press enter to accept the content within the editable table cell; iffalse
, clicking outside the cell will accept the content.editable_autoResort
(false
) - Iftrue
the column will resort (only if already sorted) after the content has been changed.editable_noEdit
('no-edit'
) - Class name on table cells to search for that are not to become editable. The search is only done within the columns set by theeditable_column
option.editable_editComplete
('editComplete'
) - Event fired after the table content has been edited.
- Pressing escape while editing will cancel any changes.
- In the demo below, click in any of the first three columns to edit the content, except for the cell containing "Peter".
- To prevent a table cell from becoming editable, add the class name
"no-edit"
to the cell. - Edited content will be accepted in the following circumstances:
- Pressing enter when the
editable_enterToAccept
option istrue
. - Clicking outside of the current editable content.
- Moving the mouse outside of the current tbody. This is done because if the content editable is still active when the user clicks on the header to sort the column, all sorts of bad things happen.
- Pressing enter when the
- Edited content will not be accepted in the following circumstances:
- Pressing Escape within the editable content.
Demo
First Name | Last Name | Age | Total | Discount | Date |
---|---|---|---|---|---|
Peter | Parker |
28 |
$9.99 | 20% | Jul 6, 2006 8:14 AM |
John |
Hood |
33 |
$19.99 | 25% | Dec 10, 2002 5:14 AM |
Clark |
Kent |
18 |
$15.89 | 44% | Jan 12, 2003 11:14 AM |
Bruce |
Almighty |
45 |
$153.19 | 44% | Jan 18, 2001 9:12 AM |
Bruce |
Evans |
22 |
$13.19 | 11% | Jan 18, 2007 9:12 AM |