search/filter rows across page with server-side processing
search/filter rows across page with server-side processing
Hi,
I have a use-case where I need to manipulate rows data across page with server-side processing.
E.g., first search rows by certain key, and then modify certain fields.
I have some code(coffeescript) like:
rowsToUpdate = dataTable.api().rows().eq( 0 ).filter (rowIdx) ->
dataTable.api().cell(rowIdx, 1).data() == "1"
dataTable.api().cell(rowsToUpdate[i], 1).data(0) for i in [0..rowsToUpdate.length-1]
I know that rows() selector-modifier doesn't really work across page with server-side(because client side only knows about current page), I wonder if there is any work around? (aka, select/filter/manipulate rows across page)
Thanks,
This question has an accepted answers - jump to answer
Answers
An update to my question:
I noticed that API
.search()
will perform a global search even in server-side (which I assume will across page).So I guess this
.search()
might be useful in my use-case.I noticed that there is also a
.column().search()
API, is this also a global search, aka, search all data across page in server-side mode?Thanks!
Short answer is yes,
column().search()
will work with server side processing. Your server side script needs to also support column based searching. This doc explains the parameters sent to the server and what is expected in return.https://datatables.net/manual/server-side
Please post if you have further questions.
Kevin
@kthorngren hi thanks!
but looks like
column(1).search(1)
still works different from something likethe search isn't actually performed and the filtered rows are not returned as the above code shows.
basically I want to find an alternative for
rows().filter(...)
in server side modeMaybe I'm misunderstanding what you are actually after. If you want to search and display certain records based on data in a certain column then use
column().search()
. The parameters sent to the server will contain info about the search term for that specific column. The table display will be updated with the result.However it sounds like you want to use
filter()
to get a list of row indexes (maybe) matching your criteria.filter()
is only a client side function without provisions to send a request to the server.Kevin