5 ms·
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
by debaserab2 13y ago
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 anything else out there that was even close to as good, though.
- enigmoid 13y agoI 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 reasonable. I couldn't even find a list of initialization options anywhere.
- theallan 13y agoA full list of options are available here: http://datatables.net/ref 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.
- freeasinfree 13y agoAlternatives such as? They use Hungarian Notation[0]; not random, but dated. [0] http://en.wikipedia.org/wiki/Hungarian_notation http://en.wikipedia.org/wiki/Hungarian_notation
- wyuenho 13y agoI wrote this: http://backgridjs.com/ http://backgridjs.com/
- debaserab2 13y agoAh, you're correct. I don't program in any language that considers hungarian notation to be a common naming convention so I haven't ran into it before. For some reason I had not stumbled on to the page that explains this until I deliberately looked for it now. As far as alternatives go, I usually specialize based on what my needs are. If I'm using a JS framework I don't have as much of a need for an all-in-one solution like datatables because the framework usually does a good job of handling things like DOM rendering and data storage without the need for a full blown table sorting library.
- kamjam 13y agoAs far as alternatives go, I usually specialize based on what my needs are. Well, the alternative is always to write it yourself. The same could be said for jQuery or any framework (and many have been advocating doing that) but it's always a trade off between experience/time/resources. I don't think it's really fair to compare a feature rich plugin that provides a lot of generic functionality vs what you can write for a very specific requirement, esp if you don't need the any/most of the functionality in the plugin! I used Datatables a few years ago extensively for a provide, I actually found it very easy to work with - but I understood the notation having come from a VBScript background a long time ago - and as others have said, it was miles ahead of anything else at the time.
- debaserab2 13y agoThat's not what I mean necessarily. You can specialize by grabbing a single purpose library.
- kamjam 13y agoSure I agree, but that's just common sense, use something that fits your purpose, it's the same for any piece of software.
- xerophtye 13y agoInterestingly enough, this is exactly what we have been working the past week at the office :) but our solutions are more general (not fixed for a table) because we need the pagination feature for many different controls
- jobowoo 13y agoWhat alternatives have you found to be better? I'd be interested in checking them out.
- kisielk 13y agoI'm not the parent, but we switched from Datatables to SlickGrid: https://github.com/mleibman/SlickGrid https://github.com/mleibman/SlickGrid Much nicer API and it's fast for large amounts of data. Unfortunately like many things it's lacking a lot of docs so you have to dig through the source of the examples.
- scr4ve 13y agoWe finally ended up picking http://dgrid.io/ http://dgrid.io/ over SlickGrid and jqGrid. As with every table component, there are some quirks, but we're really happy with it. Feels like the most modern table component to us.
- shoebappa 13y agoCan you name a few of the alternatives you found? The ability to sort on more than one column ruled out a lot of them for us.
- jonaldomo 13y agohttps://github.com/Mottie/tablesorter 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.
- debaserab2 13y agoHere'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_init/dom.html 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 DOM element layouts accepts as a string. And there's only one example. How is that sane?
- m_mueller 13y agoI don't find this a problem at all. What's indeed a problem is that it enforces a wrapper div that you cannot control using this syntax. Furthermore, plugins such as ColVis tend to be inflexible due to that wrapper.
- arethuza 13y agoTo 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.
- debaserab2 13y ago
- m_mueller 13y agoIn 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.
- jessedhillon 13y agoAs 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.
- m_mueller 13y agoThanks, 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.
- arethuza 13y agoThe 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/ http://datatables.net/development/
- theallan 13y agoDataTables 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.