Multiple tables javascript errors

Multiple tables javascript errors

TreeUKTreeUK Posts: 3Questions: 0Answers: 0
edited December 2010 in Bug reports
Great plugin, thought I'd report an issue I can repeat.
Basically if your tbody doesn't contain the same number of tds as you have ths or you use colspan on more than one table, the plugin dies on the second table.
This seems to be because colspan is only supported on one table:
Both empty cells = win.
One colspan, one empty cells (either order) = fail.
Both colspans = fail.

[code]



Type
Title
Url
Description
Live




<% if(Model.Count == 0) { %>

No stuff has been added yet

<% } %>
<% else { %>
<% foreach(var col in Model) { %>

<%: col.Type %>
<%: col.Title %>
<%: col.Url%>
<%: col.ShortDescription.GetFirstNCharactersFromString(20)%>
<%: col.Live%>


<% } %>
<% } %>



Type
Title
Url
Description
Live




[/code]

Obviously I'm only showing one table here but both tables vary only in the content and number of cells per row. This example is 6, the other is 4.

Replies

  • TreeUKTreeUK Posts: 3Questions: 0Answers: 0
    Sorry, update is:
    Although the table renders with the sorting icons, there's still a javascript error if you use colspan AT ALL.
  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin
    Yup - DataTables does not support colspan at all in the TBODY. This is intentional as it would add a lot of complexity to sorting / filtering etc. If you want to have no rows shown, just let DataTables do it and don't print the row yourself. If you want to have it there for non-Javascript users then before initialising the table just remove the row from the DOM.

    Allan
  • TreeUKTreeUK Posts: 3Questions: 0Answers: 0
    edited December 2010
    For future visitors - To change the messages displayed for the different rows take a look here http://www.datatables.net/usage/i18n which should be the internationalization section of the Usage nav item
This discussion has been closed.