-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can tablesorter contenteditable edit a field with carriage returns in it? #886
Comments
Hi @Stephen-Hazel! Right now the editable widget only grabs the text (using jQuery I'll go ahead and push an update to switch the widget to work with the contenteditable html (using jQuery's Also, to enable a user to include carriage returns, the |
That is awesome. THANK YOU!! So I just download the trunk again and it's there? Or master or whatever. Well, I'll give it a shot n see. |
Yes, the update is in the master branch, I have not push a version release yet. |
ok cool. thanks again! |
Hmmm, I'm having problems (sorry!) $("table thead th").data ("sorter", false);
$(".tablesorter").each (function () {
var ce = [], t = Number ($(this).attr ('id').substr (2));
for (var i = 0; i < ta [t][1]; i++) ce [i] = i;
$(this).tablesorter ({
theme : 'blue',
widgets: ['editable'],/*, 'resizable'],*/
initialized: function (table) /* dont unblur */
{ table.config.$tbodies.off ('mouseleave.tseditable'); },
widgetOptions: {
editable_columns : ce,
editable_enterToAccept: false,
editable_trimContent : false,
editable_autoAccept : true,
editable_autoResort : false,
editable_validate : null,
editable_focused : function (txt, colInd, el) {
el.addClass ('focused');
},
editable_blur : function (txt, colInd, el) {
dbg('ed blur txt='+txt);
el.removeClass ('focused');
},
editable_selectAll : function (txt, colInd, el) {return true;},
editable_wrapContent : '<div>',
editable_noEdit : 'no-edit',
editable_editComplete : 'editComplete'
}
})
.children ('tbody').on ('editComplete', 'td', function (ev, cfg) {
var $th = $(this),
tn = Number ($th.closest ('table').attr ('id').substr (2)),
tr = $th.closest ('tr'),
co = this.cellIndex,
ro = tr.index ();
if (tn == 1) { // autocalc curr mo,ytd timeliness perc ...etc etc |
actually, that might be me. when I validate the cell with that editComplete function, I'm using .text on it instead of .html... For now, assume it's me and sorry for buggin ya :) |
ok, it turns out to be a bit tricky to handle these multiline cells what with the div that's usually there, sometimes not (readonly cells). But it seems to be workin for me. When there are multiple lines, you get breaks in there, and spaces, greater than, and less than give you those ampersand thingies. nbspc lt, gt. I'm just gonna leave them as they are in the weirdo string and stuff em in the db that way. When I need to use the cell for a report or whatever, I'll turn the br and lt and nbsp junk into normal characters then. Hopefully this change doesn't adversely affect others who don't need linebreaks, etc. But things are werkin! |
You could use the validate function to replace the editable_validate: function (txt, orig, columnIndex, $element) {
txt = txt
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\<div\>(.*)\<\/div\>/g, '<br>$1')
.replace(/ /g, ' ');
return txt;
} Note The demo is using the widget-editable file in the master branch. Update: I had to make the Update 2: So, instead of doing a global replace on
The span in that example will still be wrapped in a div, I guess because the |
got ya. I think I'm gonna just leave the html junk in, though. Thanks |
Not an issue. Just hoping there's some trick that'll let me edit multiline cells...?
I notice that when hitting return, another row of text is added to the cell. It looks great until I tab out of the cell and then everything gets jammed onto one line.
It'd be sooo cool to be able to edit text with carriage returns or even
or whatever in a cell.
any ideas?
again, thanks for a GREAT table editor.
The text was updated successfully, but these errors were encountered: