Inline editing with Bootstrap 3
Inline editing with Bootstrap 3
sliekens
Posts: 97Questions: 17Answers: 2
The inline editing works nicely with the default styling, but it looks awful when using the Bootstrap 3 styles.
Example (click cells to edit) http://live.datatables.net/datoxopi/3/edit?output
The inline input fields don't stretch to use the full width and height of the cell.
This discussion has been closed.
Replies
Your example doesn't look too bad to me (screenshot attached). There is a bit of misalignment at the bottom that I'll look into.
Allan
That misalignment is caused by a placeholder div for inline field errors.
The
DTE_Form_Error
class hasmargin-top: 10px
. Here's what the table looks like without the error placeholder.http://live.datatables.net/datoxopi/6/edit?css,output
But removing that extra margin isn't enough for me. The "Simple inline editing" example still looks much better than what I have.
https://editor.datatables.net/examples/inline-editing/simple.html
See how the input fields make better use of the available cell width and height in that example? At least it seems that way to me.
If you add:
That helps: http://live.datatables.net/datoxopi/7/edit . I'll get that into the repo - and the margin-top issue.
The cell padding is what is causing it to be noticeably smaller than "100%" of the total cell width. That is particularly obvious in the Bootstrap case because of the cell border.
I've removed that in the above link and it matches closer the DataTables styling.
Allan
Thanks. Perhaps change 34px to 'inherit' so the height is always relative to the cell height.
Could you add a class to the <td> element when it is being edited? I would like to set padding-left and padding-right to 0 when the cell contains a text input field.
I managed to do it in JavaScript using the preOpen and preClose events, but perhaps you can put this in the source.
http://live.datatables.net/datoxopi/11/edit?output
See how the input fields stretch to the borders of the cell? This looks much better in my opinion, because input fields have their own padding.
There is still an issue with the error placeholder not being hidden on blur (or close in general), but that's a logical error rather than a styling issue.
I hadn't realised that was an option! It isn't quite perfect since if the cell has two rows of text, it doesn't just expand to fit, but that certainly looks like a better option that a hard coded value.
That does look good. I had tried that using negative margins on the input element, but that didn't work.
I don't really want to modify the cell's class, but it might be the only way. I'll look into it before the 1.6.1 release.
I think the best way to handle that will be to use the
:empty
CSS pseudo selector and make the margin top 0 when it is empty. Then we don't need to modify the error element at all.Allan
The
:empty
selector did the trick.I had to use
!important
because there is a routine somewhere that adds styles directly to the DOM element when an error occurs.If these styles can be removed when the editor is closed then the
!important
keyword is not needed.I ended up writing code that toggles class
"editing"
on the<td>
tag when it contains an inline editor. (using open/close events)Then I created a style for that class to remove all padding from the cell.
Then I removed all the styles that set negative margins on inline fields (in
editor.bootstrap.css
).The result is much better if you ask me.