The example code not taking effect

The example code not taking effect

romsokromsok Posts: 38Questions: 0Answers: 0
edited December 2009 in General
Hi,

I am new to JQuery and DataTables, and I am trying to implement the first - zero-conf option - and it is not working - I am reloading the page, but the table looks the same as before and no new features.
Here is my markup:

[code]


<!-- JavaScript, JQuery, DataTables, etc. -->



$(document).ready(function() {
$('#myTable').dataTable();
} );

Insert title here



















#
%
#
%
#
%
#
%










Some Link















Total:

















[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi romsok,

    Your initialisation code looks okay, so there much be a Javascript error somewhere (unless the JS isn't being loaded). Having a look in Firebug will confirm this.

    My guess at the error is that the header you have is quite complex. DataTables requires a single 'unique' TH element for each column. You can't have more than one unique TH element (something that I will try to address in future), but in your first column, you have two. I'd suggest reducing the complexity of your header to see if you can get that to work, and then let me know what happens.

    Thanks,
    Allan
  • romsokromsok Posts: 38Questions: 0Answers: 0
    Thank you Allan for the quick response.
    Yes, the extra header was causing PART of the problem. The code I posted above is from a JSP, generated using Spring frameworks and JSTL tags. I created a very simple one to test, and replicated the JS code in it - it works fine. Adding the extra header did cause an issue, but after removing it from both the experimental file (which works), and the actual file (which doesn't), the actual file still didn't work
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi romsok,

    So it doesn't work even with a simple header? You have 11 columns in your table - if you just put in 11 TH elements and one TR in THEAD, does that work? This should! Beyond that, it think it's down to the complexities of the header... I'm looking at the code for that just now, but can't promise anything yet. Also, you might find this demo interesting: http://datatables.net/examples/advanced_init/complex_header.html

    Regards,
    Allan
  • romsokromsok Posts: 38Questions: 0Answers: 0
    I isolated the culprit:

    It's this entry:

    [code]



    [/code]

    Not certain how, but it was breaking it. After I removed this entry, it works fine
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Gah - I'm sorry I missed that on the original post. Yes - that would cause the problem. DataTables doesn't deal with col/rowspan inside the TBODY... The closest you can get at the moment is to use something like I've done for ht my row grouping example: http://datatables.net/examples/advanced_init/row_grouping.html

    Regards,
    Allan
This discussion has been closed.