Server side processing means doing all filtering, sorting on server too?

Server side processing means doing all filtering, sorting on server too?

rlwrlw Posts: 2Questions: 0Answers: 0
edited June 2013 in General
Hi, I successfully followed the RailsCast #340 on using Datatables with Ruby on Rails which showed me how to do server side paging and server side global filter. But now I want to do per-column filtering as well and exactly match the semantics of client side filtering and sorting. I think I have four or five questions:
1. If I do server side processing with ajax, Datatables provides no sorting or filtering capabilities - everything is handled on the server, correct?
2. Rows that match the filter(s) do so because all the filters are satisfied- every per-column filter and the global filter, so all the 'where clauses' are 'anded' in the database SQL query, correct?
3. My model/database table has a couple of foreign keys to other tables so the values displayed in the resulting html table are 'through' those foreign keys. This means server side sorting and filtering has to use joins to those other tables to sort and filter on the appropriate values to match the client side semantics, correct?
4. How does Datatables handle multi-column sorting? Or does it do single column sorting and happens to preserve order from a previous sort? (or not?)
5. Looking at how Datatables passes parameters in its AJAX calls, it seems to use individually named params for filtering and sorting, such as sSearch_0, sSearch_1, sSearch_2, rather than arrays. Can this be changed to arrays?

Thanks,
-Robert

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    > 1. If I do server side processing with ajax, Datatables provides no sorting or filtering capabilities - everything is handled on the server, correct?

    Absolutely correct. Yes.

    > 2. Rows that match the filter(s) do so because all the filters are satisfied- every per-column filter and the global filter, so all the 'where clauses' are 'anded' in the database SQL query, correct?

    Also correct.

    > 3. My model/database table has a couple of foreign keys to other tables so the values displayed in the resulting html table are 'through' those foreign keys. This means server side sorting and filtering has to use joins to those other tables to sort and filter on the appropriate values to match the client side semantics, correct?

    Yes :-)

    > 4. How does Datatables handle multi-column sorting? Or does it do single column sorting and happens to preserve order from a previous sort? (or not?)

    No - it actually do a multi-column sort. In SQL terms it does something like `ORDER BY first_name ASC, last_name ASC` etc. It sends the information about each column to be sorted.

    > 5. Looking at how Datatables passes parameters in its AJAX calls, it seems to use individually named params for filtering and sorting, such as sSearch_0, sSearch_1, sSearch_2, rather than arrays. Can this be changed to arrays?

    You could modify the DataTables source. It is done the way it currently is for server compatibility. While most frameworks will deal with arrays no problem now, that wasn't the case back in 2007 when I started work on DataTables. So this is a legacy issue. I might include a flag at some point to have a 'modern' option. Or possibly when I do DataTables 2.0 I'll break a few things like that to update them correctly.

    Allan
This discussion has been closed.