Buttons tutorial suggestion

Buttons tutorial suggestion

Rusty BallingerRusty Ballinger Posts: 21Questions: 7Answers: 0

I'm pretty new to DataTables, and am not much of a JavaScript programmer; in the course of trying to get Editor to work, I blew a lot of time trying to get Buttons to show up.

(In comparison, I found DataTables really, really easy to get working with Ajax + custom formatters + sorting on hidden columns, etc.; the documentation has been great.)

I just wanted to start by seeing some buttons--any old buttons--so, I switched to the CDN-hosted files given by the download builder when I chose DataTable + Buttons; then, to my existing, working DataTable, I added this bit from https://datatables.net/extensions/buttons/:

dom: 'Blfrtip',
buttons: [
    'copy', 'excel', 'pdf'
]

When I did that, a <div class="dt-buttons"></div> element started showing up in my table wrapper, but it was empty, and I didn't see any buttons; I figured I was missing a really obvious step. I was, but it took me hours to solve it (including trying out the DataTables debugger, and creating an example on http://live.datatables.net/ ... pretty nifty tools which of course I hope to never use again).

The issues were that A) those buttons require the Flash Export or HTML5 Export plugins (or something I didn't have), and the tutorial didn't... exactly make it extremely clear that it needed those files*, and B) at runtime, I never saw an error message saying I was asking for a button I didn't/couldn't have. (Is that logged someplace where I could/would have seen it if I knew what I was doing?)

  • Yeah, now that I'm 4 hours older^H^H^H^H^H smarter, I see the "These buttons are not part of the core library" line in https://datatables.net/extensions/buttons/built-in ... but I'm thinking maybe the title of that page should be changed to "NOT Built-in buttons," cough cough. I also now see that, if I read the pdf documentation, it says it won't display if it can't, but it didn't occur to me to look for documentation on specific buttons.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,338Questions: 1Answers: 10,228 Site admin

    Interesting one - thank you for this.

    If you use pdf then it won't throw any errors if you haven't included the Flash or HTML5 files. If you were to use pdfHtml5 or pdfFlash though - it will: http://live.datatables.net/susodezo/1/edit !

    The reason it currently doesn't throw any errors is to allow for one of the Flash or HTML5 types not to be included. If they aren't, then it should fall over onto the other one. But it seems that if either are included, it just goes "fine - move on".

    I think that should change - if either is available, an error should be thrown. Does that sound reasonable from your perspective (since you are the one who went through this torture)? Thanks for sticking with it btw - I know how frustrating it can be to use library software sometimes!

    Allan

  • Rusty BallingerRusty Ballinger Posts: 21Questions: 7Answers: 0

    Welllll... might there be existing developers who are using the current behavior? I would feel better about adding a bit to https://datatables.net/extensions/buttons/ (maybe in the "Download" section) along the lines of "in order to use the example buttons below, make sure you include thus-and-such plugin, not just the core Buttons plugin." I would hate for someone else's code to break because they read more documentation than I did.

  • allanallan Posts: 62,338Questions: 1Answers: 10,228 Site admin
    Answer ✓

    Point taken, but I think its something that others will fall into as well. Indeed, if it is happening on other sites at the moment, its probably a mistake there as well. I'll put it in for v1.6 rather than a patch release.

    The download builder does have the extra buttons shown as sub-categories, but I'll look at improving the rest of the documentation as well.

    Thanks!
    Allan

This discussion has been closed.