Live data from Hacker News

DataTables – Table plug-in for jQuery

datatables.net

31–40 of 59 posts

Re: DataTables – Table plug-in for jQuery

#31

While I have found DataTables to be useful in the past, there are (thankfully) many other alternatives available today with a much saner API. DataTables might have the worst API I've ever seen in a Javascript library. Powerful, yes, but it has the most insane naming conventions I've ever seen. To this day I do not understand why so many properties are prefixed with random letters. There was a time when there wasn't a…

In typical HN fashion the most cranky post gets voted to the top.

- Hungarian notation is 'the most insane naming convention' you have ever seen? Really? I'm guessing you haven't seen a lot.

- 'There are many alternatives with a much saner API' - proceeding with not naming any, and the ones mentioned below all are lacking in features compared to DataTables - everything else I've seen tends to be a one trick pony. Obviously something with not many features is going to have a simpler API.

Please note: I do agree that the API could be better - also, it depends on how many powerful features you want, whether DataTables is going to be worth it. As someone who usually develops in rich desktop environments I tend to demand more of tables, and to program all those features from scratch would use an insane amount of time on the web.

Re: DataTables – Table plug-in for jQuery

#32

While I have found DataTables to be useful in the past, there are (thankfully) many other alternatives available today with a much saner API. DataTables might have the worst API I've ever seen in a Javascript library. Powerful, yes, but it has the most insane naming conventions I've ever seen. To this day I do not understand why so many properties are prefixed with random letters. There was a time when there wasn't a…

The naming convention annoyed me for about 10 minutes then I just got on and used it - at least the notation is documented:

http://datatables.net/development/

Re: DataTables – Table plug-in for jQuery

#33
DataTables author here - I've often wondered what article or software I might write to see if I could get onto the hacker news front page. Apparently the trick is to wake up one morning and be very pleasantly surprised to see existing software already there :-)

Very happy to answer any questions if anyone has any!

Re: DataTables – Table plug-in for jQuery

#35
1. Keep Excel spreadsheet in a shared network location

2. Set to autogenerate webpage on every save

3. Clean up crufty HTML with jQuery

4. Display using DataTables

5. Proit!

This hacky hackerson of a hack was great way to get around having to build a CRUD app and go through IT channels to have something deployed on the network, and still keep things simple enough for extremely entry-level end-users.

Thanks for DataTables, Allan!

Re: DataTables – Table plug-in for jQuery

#36

While I have found DataTables to be useful in the past, there are (thankfully) many other alternatives available today with a much saner API. DataTables might have the worst API I've ever seen in a Javascript library. Powerful, yes, but it has the most insane naming conventions I've ever seen. To this day I do not understand why so many properties are prefixed with random letters. There was a time when there wasn't a…

In typical HN fashion the most cranky post gets voted to the top. - Hungarian notation is 'the most insane naming convention' you have ever seen? Really? I'm guessing you haven't seen a lot. - 'There are many alternatives with a much saner API' - proceeding with not naming any, and the ones mentioned below all are lacking in features compared to DataTables - everything else I've seen tends to be a one trick pony. Obv…

As far as alternatives go, it's trivial to reproduce most of DataTables' functionality with AngularJS by binding an array of objects to a template for a table. Of course DataTables has been available for years, but I have to agree that the API is atrocious. There's no excuse to be using Hungarian Notation in 20xx, but even without the naming conventions the way some of the functions are invoked and arguments are constructed is just bizarre. Parsing HTTP parameters is laborious and error-prone IIRC.

(Again IIRC some arguments, such as which column to sort on by default, are the actual integer index into the columns array -- i.e. pass a 1 to sort on the second column. The last time I saw anything like this was when I was looking at Quake3 source, written in C!)

However it does the job well once it's all set up and for a long time it was miles ahead of any other option. Only ExtJS and YUI grids are/were better but those require large frameworks and a number of assets to be in place. I would never advise someone to use it today though, I have to say. I used it once for a critical project and in retrospect I would have rolled my own, despite time constraints.

Re: DataTables – Table plug-in for jQuery

#37

While I have found DataTables to be useful in the past, there are (thankfully) many other alternatives available today with a much saner API. DataTables might have the worst API I've ever seen in a Javascript library. Powerful, yes, but it has the most insane naming conventions I've ever seen. To this day I do not understand why so many properties are prefixed with random letters. There was a time when there wasn't a…

DataTables author here - I completely agree that the API is far from the best, which is why v1.10 will include an entirely new "modern" API (with a shim for the old API to provide full backwards compatibility).

The prefix letters aren't random, but they aren't elegant either. When I first wrote DataTables I was working for a company which required the use of Hungarian notation in their coding standards, so I was trained to write that way - I've never changed it because I didn't want to break backwards compatibility. Having said that, v1.10 provides a camelCase layer, which will be what is documented at the API / options with 1.10. Again the Hungarian notation will be supported for full backwards compatibility.

v1.10 is available in github (1_10_wip branch) if you want to try it. It is pre-beta, but almost ready to roll as a beta - I just need to write the documentation.

Re: DataTables – Table plug-in for jQuery

#38
post #5

While I have found DataTables to be useful in the past, there are (thankfully) many other alternatives available today with a much saner API. DataTables might have the worst API I've ever seen in a Javascript library. Powerful, yes, but it has the most insane naming conventions I've ever seen. To this day I do not understand why so many properties are prefixed with random letters. There was a time when there wasn't a…

I agree with your sentiment. I found datatables initially easy to set up and use, but I soon found the documentation to be sorely lacking. Searches for the most basic customizations led to SO answers outlining ugly workarounds when all I really needed to know was the name of the right flag. The examples on the site aren't general or plentiful enough, and they assume more prior knowledge of the plugin than would seem…

A full list of options are available here: http://datatables.net/ref . However, I totally accept that the documentation isn't up to scratch, which I why I'm working on completely redoing it.

I'd be interested to know of any particular pain points you had so I can ensure they are addressed.

Re: DataTables – Table plug-in for jQuery

#39

Earlier quoted context omitted.

https://github.com/Mottie/tablesorter has multiple sorting using the shift key. I alternate between this and DataTables. The hungarian notation threw me off at first too. Far from insane though.

Here's an example of what you have to do in datatables to get the elements displayed around the table itself styled (such as a search bar, pagination, or table meta information) https://datatables.net/release-datatables/examples/basic_ini... So, in order to adjust the styling of DOM elements around the datatable, you need to understand a very specialized form of syntax that one particular property that controls all D…

To control the structure of whats put in the DOM your are going to need something that looks like a template - so it's never going to be pretty and as soon as you choose any approach to templating it's probably going to upset a lot of people.

I agree that the syntax is a bit on the terse side - but it's not "insane" and at least it is there, logical and documented.

Re: DataTables – Table plug-in for jQuery

#40

Earlier quoted context omitted.

In typical HN fashion the most cranky post gets voted to the top. - Hungarian notation is 'the most insane naming convention' you have ever seen? Really? I'm guessing you haven't seen a lot. - 'There are many alternatives with a much saner API' - proceeding with not naming any, and the ones mentioned below all are lacking in features compared to DataTables - everything else I've seen tends to be a one trick pony. Obv…

As far as alternatives go, it's trivial to reproduce most of DataTables' functionality with AngularJS by binding an array of objects to a template for a table. Of course DataTables has been available for years, but I have to agree that the API is atrocious. There's no excuse to be using Hungarian Notation in 20xx, but even without the naming conventions the way some of the functions are invoked and arguments are cons…

Thanks, that's way more helpful. In my case I didn't think about using Angular since I wanted the templating to be serverside in general - it's an interesting idea to use it only for the asynchronous parts.

I don't get the hate for Hungarian notation and 0 based column index though. I wouldn't use Hungarian myself but I don't complain about it either - for dynamic typed languages it makes enough sense to me, since it conveys the desired type information without too much clutter. How would you specify the column of a html table? IDs don't really make sense since it could be inconsistent or missing - I guess a 1 based index might be better for consistency with CSS, but it's not really something that makes me want to switch framework.

Post reply on HN