do not alter filter row in header
do not alter filter row in header
I have a row of filters in the row below the headers.
<thead>
<tr><td>col1</td><td>col2</td><td>col3</td></tr>
<tr><td><input></td><td><select></td><td><input></td><td><input></td></tr>
</thead>
It appears datatables is wrapping my second-row form elements inside a <span class="dt-column-title"><select></span> which causes invalid html ("Element div not allowed as child of element span in this context.") because my <select> is a tom-select which adds a div.
Is there a way to tell dt to ignore the second header row or is there a better way to handle this?
This question has an accepted answers - jump to answer
Answers
Unfortunately no, there isn't an option to have it not wrap the content in a span at the moment. The idea there was to introduce a semantically neutral element to allow layout control for things like the ordering icons and ColumnControl.
Does it actually cause any rendering issues, or is it just a strict HTML error? I could possibly make the
spanadiv, or add an option for that, but it is already a child of adiv(used as the flex container), sospanwas the obvious choice.Allan
Without seeing a test case with the issue it's hard to say. I copied your code into this test case:
https://live.datatables.net/bunisiqu/1/edit
I did get this error:
The problem with the code above is there are three columns in the top header but four in the bottom. Removing the last column in the second header fixes the issue. Not sure if that is the same issue for you. If not please update the test case to show the issue you are having. Or provide a link to a test case showing the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@kthorngren your test case is accurate but as I said above, I am using tom-select on the
<select>element. This js lib adds a<div>element after the<select>. When dt wraps the contents of the<td>you now get something likenote the injected
<div>after the<select>This is invalid HTML - a div inside a span.
I can't figure out how to add the tom-select lib to your test case generator, so I cannot provide the exact situation.
@allan it renders fine. The problem is meeting .gov standards for html in my client's use case.
https://live.datatables.net/bunisiqu/2/edit?html,css,js,output
here is a test case. you have to inspect the html around the select element to see the problem.
I think the only realistic way to address this is to change the
spanto be adiv. I can't do that for DataTables 2.x, but I'm willing to consider that change for DT3, which I'm working on at the moment. That said, it could be an optional parameter for DT2. Would that resolve the issue for you?Allan
@allan I think optional would solve it for me, yes. thanks!
I'll aim to get that implemented on Monday. Also aiming to make a release for DT on Monday, so it should be a quick turn around
Allan