News for hackers. Stuff that matters.
Re:37signals doesn’t like you sorting stuff. Are you just re... by pinaceae on Tuesday December 20, 2011 @02:43PM (#3374814)
ha, I would wager that there is a simpler reason: sortable tables in HTML are nearly impossible to implement.

once you have a lot of data, you want fixed column headers. stacked sorting (column A first, then B), a lot of things suddenly become needed additions.

and where do you sort? front end or back end? how much data are processing?

just look at google spreadsheets and you'll see how sub-optimal it is.

Re:37signals doesn’t like you sorting stuff. Are you just re... by ByteMuse on Tuesday December 20, 2011 @11:39PM (#3376380)
sortable tables in HTML are nearly impossible to implement.

This is definitely a solvable (and solved) problem.

and where do you sort? front end or back end? how much data are processing?

If you have all the data loaded clientside, sort it there. Otherwise, just make a call to the server to query for data compliant with the new sort order. Both methods are fairly low cost.

Re:37signals doesn’t like you sorting stuff. Are you just re... by speleding on Wednesday December 21, 2011 @03:38PM (#3379035)
Sorting on the back end is generally not cheap unless your dataset is very small (or unless it's indexed, but with arbitrary sorting it wouldn't be).
Re:37signals doesn’t like you sorting stuff. Are you just re... by mbell on Tuesday December 20, 2011 @08:19PM (#3375967)
I'm confused as to why this is hard. I code primarily in java with JSF for views and this is possibly the simplest thing to do in any of my projects. Using something like primefaces I generally never even need to write a line of javascript unless i need to customize some action and I can use theme roller / stock css for appearance.

Example: http://www.primefaces.org/showcase-labs/ui/datatableComplex....

This is working client side, if i want to do server side its as simple as implementing a single class that pushes the sorting/filtering/paging off the to the database:

Example: http://www.primefaces.org/showcase-labs/ui/datatableLazy.jsf

It can't really be much harder to do this on other stacks can it?

Re:37signals doesn’t like you sorting stuff. Are you just re... by rrrazdan on Wednesday December 21, 2011 @12:55AM (#3376516)
JSF is a bit of exception. I haven't 'really' searched but its harder to do this in say Struts. What rule of thumb for the data size do you use when choosing between client side and server side sorting?
Re:37signals doesn’t like you sorting stuff. Are you just re... by mbell on Wednesday December 21, 2011 @11:49PM (#3380440)
I wouldn't say there is a hard rule of thumb and there are three levels of operation possible, at least with primefaces:

1) All row data sent to client side, all paging done on client

2) Backing controller contains a List with all data in memory, client only gets 1 page at a time via ajax updates.

3) A truly 'Lazy' data model, ajax request for a new page of rows, controller references a lazy data model that fetches just that page worth of data from the database tier and sends it to the client.

In practice I really only use #2 and #3 normally. Unless the application has a bad internet connection as a requirement I assume its faster or negligible to fetch pages via ajax vs loading them all into the client up front. As far as choosing between #2 and #3, for my applications its usually obvious, the table either contains 5-25 items (go with 2) or thousands of items (go with 3).

In the middle ground i guess it comes down to loading: Can you afford to use more memory in the web tier or would you rather keep that memory usage down and suffer slightly long update times? Assuming your database is well designed it should only had maybe 10ms onto your response time to just grab the page from the database vs already having it in memory.

Re:37signals doesn’t like you sorting stuff. Are you just re... by mattadams on Tuesday December 20, 2011 @03:12PM (#3374926)
Data tables (jQuery addon) does a pretty good job with HTML tables.
Re:37signals doesn’t like you sorting stuff. Are you just re... by tptacek on Tuesday December 20, 2011 @03:32PM (#3375013)
If you can push all your data to the front-end all at once, yes. DataTables makes this pretty straightforward.

Otherwise, his point stands. DataTables has hooks for this stuff, of course, but that's just a way of saying "DataTables doesn't itself solve this problem".

Re:37signals doesn’t like you sorting stuff. Are you just re... by arethuza on Wednesday December 21, 2011 @06:27AM (#3377169)
I rather like the fact that DataTables doesn't try and solve the whole problem (front end and server back end) - otherwise you end up with things like ASP.Net server controls and DataGrids which are really just an attempt to port desktop development approaches to the web - creating an unpleasantly leaky abstraction along the way.

I find that using DataTables as front end and hooking it up to a backend is pretty straightforward and results in a nice separation of concerns - let the server/database worry about paging, sorting, searching and filtering. Of course, if you have a relatively small amount of rows then just let DataTables do all the work - but at least you have the choice.

Re:37signals doesn’t like you sorting stuff. Are you just re... by irahul on Wednesday December 21, 2011 @06:40AM (#3377202)
> If you can push all your data to the front-end all at once, yes. DataTables makes this pretty straightforward.

Paginagtion(ajax or page reload takes care of it). I use slickgrid https://github.com/mleibman/SlickGrid; pagination is straight forward, filtering takes some work. But do the hook once, and wrap the table in jquery-ui css framework's ui-widget, and you have a good looking, working table.

> but that's just a way of saying "DataTables doesn't itself solve this problem".

slickgrid is sortable, but filtering needs work. In fact, "slickgrid doesn't do everything" is part of its philosophy.

I have come to opposite conclusion that of author's. Having an excel sheet replacement in your repertoire is important, especially when you are replacing enterprisy stuff.

Re:37signals doesn’t like you sorting stuff. Are you just re... by dreamdu5t on Tuesday December 20, 2011 @06:09PM (#3375612)
Data tables was too slow for us over using 500+ rows. We went with SlickGrid... which is faster but just all over the place.
Re:37signals doesn’t like you sorting stuff. Are you just re... by rufo on Tuesday December 20, 2011 @07:10PM (#3375787)
I found DataTables was much, much faster when I passed a JSON data hash - I think the DOM manipulation is what normally kills it. We've got some tables of several thousand rows in a small internal app and performance is fine, even in older IEs. (I think I tested up to several tens of thousands before IE started to be unreasonably slow - YMMV, of course.)
Re:37signals doesn’t like you sorting stuff. Are you just re... by gruseom on Tuesday December 20, 2011 @11:06PM (#3376318)
just look at google spreadsheets and you'll see how sub-optimal it is.

How is it sub-optimal?

One of my jobs is to make a UI that gets this right, so I'd appreciate hearing what you (or anybody) find deficient in the way online spreadsheets do this.

Re:37signals doesn’t like you sorting stuff. Are you just re... by pinaceae on Wednesday December 21, 2011 @03:31AM (#3376818)
excel is the reference. it is so ridiculously optimized, it is not even funny.

outside of spreadsheets, take the itunes simple list view as a baseline. the 'simple' things are important. double-clicking the column border resizes the column to fit the longest text, etc.

Re:37signals doesn’t like you sorting stuff. Are you just re... by lubujackson on Tuesday December 20, 2011 @03:49PM (#3375081)
Just add some JS and call it a day. http://www.kryogenix.org/code/browser/sorttable/
Re:37signals doesn’t like you sorting stuff. Are you just re... by dools on Tuesday December 20, 2011 @03:59PM (#3375136)
It is not difficult at all. You sort on the backend where your data is using your RDBMS then you display it.