Is TableTools compatible with XHTML ?

Is TableTools compatible with XHTML ?

andrews812andrews812 Posts: 4Questions: 0Answers: 0
edited July 2013 in TableTools
Hello, all!

I suppose that TableTools is NOT compatible with XHTML.

In details:

I'm trying to integrate DataTables (1.9.4) and TableTools (2.1.4, as part of DataTables archive) into my XHTML web-portal.
Web-server returns content as "application/xhtml+xml". I'm doing trivial TableTools initialization:

[code]
$(document).ready(function() {
var oTable = $('#table1').dataTable( {
"bProcessing": true,
"sAjaxSource": "/cgi-bin/inventory?command=operators&format=json",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/DataTables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
},
"iDisplayLength": 25,
"oLanguage": {
"sUrl": "/locale/ru_RU.KOI8-R/DataTables.json"
}
} );
} );
[/code]

It results in JavaScript exception(s):

[quote]
uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://x.x.x.x/DataTables/extras/TableTools/media/js/ZeroClipboard.js :: anonymous :: line 134" data: no]

Line 0
[/quote]

One exeption per one button. And, as follows, all buttons except "Print" are not working. Browser don't try to load Flash-applet ever. All works fine if content returned as "text/html".

Below is the line 134 of ZeroClipboard.js:

[code]
this.div.innerHTML = this.getHTML( box.width, box.height );
[/code]

I'm not so familiar with XHTML/JavaScript programming, but, AFAIK, there's no innerHTML component in DOM of XHTML standard.

Any ideas?
Thanks!

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    > there's no innerHTML component in DOM of XHTML standard.

    Correct - but all browsers implement it I think.

    I've just tried changing my default TableTools example to use XHTML and it seems to work just fine. So, can you link to a test case showing the issue please ( http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read# ).

    Allan
  • andrews812andrews812 Posts: 4Questions: 0Answers: 0
    Sorry for delayed answer!
    I didn't find how to get JS Bin to load html-document from remote server. So i've placed two test pages entirely remotely. They are almost identical, but:

    http://www.amplilogic.com/table.php - has XHTML doctype and returned with "text/html" content-type
    http://www.amplilogic.com/table2.php - has XHTML doctype and returned with "application/xhtml+xml" content-type

    The first works very well, the second throws javascript exceptions.
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Excellent - thank you for this.

    The fix is to replace:

    > this.div.innerHTML = this.getHTML( box.width, box.height )

    with:

    [code]
    this.div.innerHTML = this.getHTML( box.width, box.height ).replace(/&/g, '&');
    [/code]

    The commit for this is here: https://github.com/DataTables/TableTools/commit/e7e81c1

    Allan
  • andrews812andrews812 Posts: 4Questions: 0Answers: 0
    Thanks for your help, Allan! Now it works!

    I have two subsequent questions:

    1. When i click "Excel" button, browser opens save-file dialog and offers to save file with .csv extension. Well, i change .csv to .xls and then try to open file in OpenOffice (3.2.1). Although the file has .xls extension, OpenOffice seems treat it as .csv and opens import text dialog. Is it bug or feature?

    2. Should data be encoded in Unicode to generate xls/pdf files with correct non-latin characters displaying?
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    1. Not so much a feature as simply how it works. The "Excel" export form TableTools is a bit of a cheat - its a CVS file with UTF16-LE encoding. Excel will open it just fine (OO.org should as well), but it is done that was as writing a proper XLS file format was turning out to be a fair amount of work. The CVS export is an interim step until I manage to get some time to write an XLSX output for TableTools.

    2. XLS export is UTF16-LE encoded and CVS UTF-8. The PDF export however doesn't support UTF-8 or 16. That's a limitation of the AlivePDF library unfortunately and I've never found a way around it. I've been looking for an alternative library, but the only real option I've found thus far is about 600K in size, which makes it not really an option!

    Allan
  • andrews812andrews812 Posts: 4Questions: 0Answers: 0
    Thanks for fast replying, Allan!

    After some tests i found that "Print" button also doesn't work correctly for "application/xhtml+xml" content:

    - it does not "expand out" table leaving only previously displayed items
    - splash screen does not appear after clicking the button
    - browser does not return to main screen after pressing escape

    the test cases above shows the issue.

    After pressing "Print" i see javascript error in console:

    [quote]
    nParent is null
    var nChildren = nParent.childNodes;
    TableTools.js (line 1970)
    [/quote]
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    I've just pushed a few more changes to Github to fix this.

    Allan
This discussion has been closed.