Set max no of records in PreviewOverlay

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
marisoft
User
Posts: 209

Set max no of records in PreviewOverlay

Post by marisoft »

Hello,

Is it possible – maybe by using some server event code – to set the maximum no of detail records shown using PreviewOverlay ?

Best Regards
/Poul


mobhar
User
Posts: 11726

Post by mobhar »


marisoft
User
Posts: 209

Post by marisoft »

Thanks.

But will this approach not LIMIT the shown details in all cases, also when I click on the button to see / edit the detail records ?
What I want is the PreviewOverlay display to be limited.

Cheers
/Poul


mobhar
User
Posts: 11726

Post by mobhar »

Then you may simply add conditional if for your case in "Recordset_Selecting" server event:

if (CurrentPageID() == "preview") { // only for Detail Preview area or Detail PreviewOverlay area
// your code to filter the recordset ...
// ...
}


marisoft
User
Posts: 209

Post by marisoft »

I am having a bit of problem with this. In the other thread you said in reply to:
Filter with LIMIT doesn't work...you must use another one...
"Yes, that's why I recommend to use "Recordset_Selecting" server event to modify the $filter that match with the search/filter criteria."

But the function ew_AddFilter($sfilter, "Field1 = 1234") ads to the where clause in the select statement:
$filter = "(" . $filter . ") AND (" . $newfilter . ")";

So how can I limit this to say 15 records ?

/Poul


mobhar
User
Posts: 11726

Post by mobhar »

You cannot limit for the certain number of records. Customizing the Filter String will limit the recordset based on the criteria you defined.


marisoft
User
Posts: 209

Post by marisoft »

OK thanks.

This would be very difficult in this situation so I guess I will have to live with it as is.

/Poul


mobhar
User
Posts: 11726

Post by mobhar »

Well, I think I've just found out the solution for your case. Simply put the following code in "Row_Rendered" server event that belongs to your detail table:

// in this example, maximum records that displayed are 3; adjust it to yours!
if (CurrentPageID() == "preview" && $this->RowCnt > 3) {
$this->RowAttrs["style"] = "display: none";
}


Adam
User
Posts: 480

Post by Adam »

This is a better, flexible solution - especially when there are many records (the example shown is for a requests table where RequestID is the key field):

// Recordset Selecting event
function Recordset_Selecting(&$filter) {
if (CurrentPageID() == 'preview') {
$filter2 = @$_GET['f'];
$filter2 = TEAdecrypt($filter2, EW_RANDOM_KEY);

    if ($filter2 == '')
        ew_AddFilter($filter, "1 = 0");
    else {
    //  $filter3 = ew_ExecuteScalar("SELECT MIN(`RequestID`) FROM (SELECT `RequestID` FROM `client_requests` WHERE {$filter2} ORDER BY `RequestID` DESC LIMIT 0, 10) AS `preview_filter`");
    //  ew_AddFilter($filter, "`RequestID` >= '{$filter3}'");
        ew_AddFilter($filter, "`RequestID` >= (SELECT MIN(`RequestID`) FROM (SELECT `RequestID` FROM `client_requests` WHERE {$filter2} ORDER BY `RequestID` DESC LIMIT 0, 10) AS `preview_filter`)");
    }
}

}


Post Reply