Answer the question
In order to leave comments, you need to log in
API, how to find out the page where the element is located?
Hello. Maybe I asked the wrong question. Let me explain.
I have API (python) + Front (VUE). There is pagination. There is a task, to open the list of workers, and to allocate the certain worker. To do this, I need to know which page this worker will be on, how is this done?
Or another example, searching for a message in a forum, how to find out on which page of the forum a message will appear.
I see only one solution, getting a list of all records from the database, and simply iterating over all the rows. When the required ID is found, return the row number.
Answer the question
In order to leave comments, you need to log in
In the general case, you have sorting by some field, you need to get the number of records with a query corresponding to the sorting and direction and the value less/greater than the desired record. Sounds complicated, let me explain with an example. If you sort by id, then you need the id of the record you are looking for and a query like where id < id_search ORDER BY id ASC|DESC, if by date, then where date < date_search ORDER BY date ASC|DESC
i.e. you need to find the number of records in your table before the one you are looking for. Well, knowing the page size - you can find on which page your desired entry will be.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question