Chumper / Datatable

This is a laravel 4 package for the server and client side of datatables at http://datatables.net/
https://github.com/Chumper/Datatable
388 stars 154 forks source link

How to search from backend #287

Closed marnone closed 9 years ago

marnone commented 9 years ago

Hi Chumper,

Is there a way I can use the Datatable::query object to search from the backend, that is, without having to use datatables on the frontend?

Right now, I only show like 100 results per "page", I am also using deferRender and infinite scroll. I want the user to be able to type in a search param and be able to "select all" (which I am handling with checkbox on every row), even rows which are not on the screen and not yet loaded into the table.

Right now, I am using my own controller function to select entire result set based on simple criteria (but not search). This works well.

I'd like to be able to use datatables built-in search to return a result set on the backend so I could extract the primary keys (for the checkbox values). I'm sure I could write my own "LIKE" query to approximate the search results myself but I need to ensure the same results selected by my own query would be selected by Datatables/Chumper.

If I use my own query, it may differ slightly and the user may see that they have something selected but really they don't. That's why I'd like the search to go through chumper engine and not my own function. Is there a way to do this?

I tried looking over the Chumper code but I could not find a function that allowed me to search.

Thanks in advance,

-Mike

minhbang commented 9 years ago

Now, using develop branch, you can extends chumper engine...

marnone commented 9 years ago

Thanks @minhbang , I looked at the Chumper code and I was able to see that it did a "LIKE" search on each column. Writing my own SQL query to search the database columns with a %LIKE% query, I was able to get the results I was looking for.