search/filter rows across page with server-side processing

search/filter rows across page with server-side processing

yichozyichoz Posts: 4Questions: 1Answers: 0

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

  • yichozyichoz Posts: 4Questions: 1Answers: 0

    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!

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    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

  • yichozyichoz Posts: 4Questions: 1Answers: 0

    @kthorngren hi thanks!

    but looks like column(1).search(1) still works different from something like

    dataTable.api().rows().eq( 0 ).filter (rowIdx) ->
            dataTable.api().cell(rowIdx, 1).data() == "1"
    

    the search isn't actually performed and the filtered rows are not returned as the above code shows.

  • yichozyichoz Posts: 4Questions: 1Answers: 0

    basically I want to find an alternative for rows().filter(...) in server side mode

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited January 2018 Answer ✓

    Maybe 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

This discussion has been closed.