Jump to row for server side implementation?

Jump to row for server side implementation?

KonradKonrad Posts: 2Questions: 1Answers: 0

Hi,

I load my data through an ajax .php controller and with server-side set to TRUE.

What I am trying to achieve is:
1) either display only ONE row
2) jump to the correct page of the datatable and highlight "the ONE" row

The row should be selected by its PK from the controller, so if the user edits entry#537, dataTables should display/jump to the row with ID #537 (which is actually displayed in column 0).

These were my attempts:
1) SEARCH
1.1) after initializing the table I tried to call search() with the search parameter and the respective column. So far this works, however, it does the SMART SEARCH no matter what, so when I want to display ID#7, I will get 7, 17, 27, 37, ... and so on. Switching to regEx doesn't return any results at all. (I can post the regex, which is pretty straight forward..?!)
1.2) I also tried calling search() on the global search, but this obviously won't really work, since most of the rows will contain the ID. Once again, I could not get this to work with regEx
2) FILTER - no luck here either, very similar to the problems with SEARCH.
3) I also tried using the API extension jumpToData() -> https://datatables.net/plug-ins/api/page.jumpToData()
This simply did nothing at all, I looked at working jsFiddle examples, which do what I try to achieve. However, it won't work on my side. My guess is, that this doesn't work for ajax data sources?

So, to sum up: how am I able to apply a search for an integer value for one specific column, after table loading?
Any help would be much obliged - thanks in advance. :)

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    page.jumpToData() knows which page to jump to because it can search through the data on the client-side and determine which page the data is present on when client-side processing. That obviously isn't possible with server-side processing.

    If you want to jump to a specific page based on the data when server-side processing you would need to query the server to find out what page to jump to.

    how am I able to apply a search for an integer value for one specific column, after table loading?

    Use column().search().

    Allan

  • KonradKonrad Posts: 2Questions: 1Answers: 0

    Hi Allan,

    thank you for your reply!

    For the part 1.1) I remembered that I was overriding the search logic in my server-side script, since I was combining DataTables with a queryBuilder component. That's why every search for ID=7 also returned 17, 27, etc; since the code for this was quite messy, I'd rather not boil that up again.

    To your reply for page.jumpToData, yes it is obvious that I can't search client-sided for data, when I query it from the server. :smile: However, I couldn't exactly wrap my head around the timing of the initalization and therefore do the correct search. I would need to init the table with my search parameters (in my case ID=7), this would also trigger my "extended" search procedure.

    I ended up pre-loading my queryBuilder with the desired search instructions and build the table from there, which works as smooth as it should.

    Therefore the error was fully on my side and you can close this question - again thanks for your time and this great piece of programming.

    Have a nice day,
    Konrad

  • KonradKonrad Posts: 2Questions: 1Answers: 0

    Hi Allan,

    thank you for your reply!

    For the part 1.1) I remembered that I was overriding the search logic in my server-side script, since I was combining DataTables with a queryBuilder component. That's why every search for ID=7 also returned 17, 27, etc; since the code for this was quite messy, I'd rather not boil that up again.

    To your reply for page.jumpToData, yes it is obvious that I can't search client-sided for data, when I query it from the server. :smile: However, I couldn't exactly wrap my head around the timing of the initalization and therefore do the correct search. I would need to init the table with my search parameters (in my case ID=7), this would also trigger my "extended" search procedure.

    I ended up pre-loading my queryBuilder with the desired search instructions and build the table from there, which works as smooth as it should.

    Therefore the error was fully on my side and you can close this question - again thanks for your time and this great piece of programming.

    Have a nice day,
    Konrad

This discussion has been closed.