Set max no of records in PreviewOverlay
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
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
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
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 ...
// ...
}
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
You cannot limit for the certain number of records. Customizing the Filter String will limit the recordset based on the criteria you defined.
OK thanks.
This would be very difficult in this situation so I guess I will have to live with it as is.
/Poul
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";
}
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`)");
}
}
}