This topic is locked

Pagination on List Page

2/16/2012 5:46:51 AM
PHPRunner General questions
U
uli author

I have to go through the sql result to do some checks and sort out some records by condition.
I do this in the event "before record processed".

But the pagination and total number of records remains as with the complete list.
I would be happy if somebody could point me to where to change these parameters.

Sergey Kornilov admin 2/17/2012

The best approach is to modify WHERE clause in BeforeSQLQuery event. In this case the number of records and pagination will be correct.
If you do it manually in "before record processed" event there are always going to be some issues. For example, your "records per page" dropdown box says 20 records while only 15 records will be shown. Besides that, you don't know how many records that are not on the current page will be shown as "before record processed" event is only applied to records on the current page.

U
uli author 2/21/2012

Thanks Sergey for your reply.

You pointed at the problem I face.

The script that sorts out the records to be displayed can not be represented in a WHERE clause.

Is there a way to have access to the complete array resulting of the query, instead of going to it record by record?
Regards

Ulrich

Sergey Kornilov admin 2/21/2012

You can build your own SQL Query in BeforeProcess event, execute it and get a full access to all data on the page.
You can also tell us a bit more about your task. There might a better workaround available.

U
uli author 2/23/2012

The tasks is quite easy, but I found no way to form a SQL query to solve it.

We have devices at stock. These devices are for rental business. So they go out of stock to customer and come back after a while.

A logform is filled out by an assistant every time a deviced is moved out or into stock.

The record has fields date, direction (out / in), dev_ID .....
To find out which devices are at stock I used to have this query:
SELECT *, MAX(device_log.date) AS max_date FROM device_log
...
WHERE (device_log.action_ID ='out' OR device_log.action_ID ='in')

GROUP BY device_log.dev_ID

HAVING (device_log.date = max_date) AND device_log.date.action_ID = in
May be because PHP Runner has some problems to process "HAVING" clauses the results were not correct in some cases.
So I decided to sort out the records to be listed using a PHP script placed in the "before record procedded" chapter.

This ended up in the pagination problem, see beginning of the thread.