How to start - confused

How to start - confused

bartek4cbartek4c Posts: 5Questions: 0Answers: 0
edited September 2011 in General
Hi

I am trying to export data from my table to Excell. However I cannot even start the dataTable. Am I doing some dummy mistake somewhere?

This is my exemplary code which does not work:

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



TEST












$(document).ready(function () {
$('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/js/copy_cvs_xls_pdf.swf"
}
});
});









1


2


3





4


5


6





7


8


9








[/code]

Its rather simple website and I would like to be able to export this table to excell. I have even imported all of the js files to make sure I do not miss anyone. PLEASE HELP I AM CONFUSED !!!

Regards,

Bartosz

Replies

  • bartek4cbartek4c Posts: 5Questions: 0Answers: 0
    Just came up to me. Should I set anything in CSS to make dataTables to work?

    Bartosz
  • bartek4cbartek4c Posts: 5Questions: 0Answers: 0
    Hi

    Even though I have added this bit to the head of the page

    [code]

    @import "/Styles/demo_page.css";
    @import "/Styles/demo_table.css";

    [/code]

    It still does not seem to work

    Bartosz
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    It's not entirely obvious at first, but datatables REQUIRES a element in your to establish the columns in the header. and your regular rows MUST be inside a

    [code]




    Col A


    Col B


    Col C







    1


    2


    3





    4


    5


    6





    7


    8


    9





    [/code]
  • bartek4cbartek4c Posts: 5Questions: 0Answers: 0
    Great!

    Thanks for help. Couple more questions however. I cannot run any of the functions from the top buttons apart of "print". I have noticed the same issue with examples from the download folder. When I open examples on the datatable.net website, after clicking Excel dialog box with destination folder appears. When I do the same with examples provided in download folder nothing happens (the same as in my application). Why is it so? Is it normal behavior? Does a website need to have any server side script to make it work?

    Regards

    Bartosz
  • bartek4cbartek4c Posts: 5Questions: 0Answers: 0
    Hi

    Sorry. One more question. Are those and elements absolutely necessary. Final table I am planning to use for this plugin runs as .aspx website. I create it dynamically from database every time the page opens. I really don't know how could I implement those two tags within the table structure while creating it. Mostly because I use controller to build it up.

    Any help highly appreciated!!!!!!!

    Bartosz
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    yes, absolutely necessary.

    I don't use TableTools often, so I can't help you with your other question.
  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    As fbas says, the THEAD and TBODY are mandatory (as noted here: http://datatables.net/usage/#prerequisites ). It basically allows DataTables to know what is the header and what is the body - otherwise it has no way of telling what is what. As for how to get ASP to put those elements in place, you might need to ask in an ASP forum (I'm not an ASP person myself, so I'm afraid I don't know). A search of this forum might yield some reasons as well, as I know people have done it before.

    > I cannot run any of the functions from the top buttons apart of "print"

    This is almost certainly because the SWF file isn't being loaded (or you might not have the Flash plugin). Make sure that sSwfPath is pointing to the right file, and that you aren't getting any 404 errors in the server error log.

    Allan
This discussion has been closed.