Page 1 of 1

Set max no of records in PreviewOverlay

Posted: Mon Nov 21, 2016 8:31 pm
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


Re: Set max no of records in PreviewOverlay

Posted: Tue Nov 22, 2016 12:07 pm
by mobhar

Re: Set max no of records in PreviewOverlay

Posted: Tue Nov 22, 2016 2:58 pm
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


Re: Set max no of records in PreviewOverlay

Posted: Tue Nov 22, 2016 4:20 pm
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 ...
// ...
}


Re: Set max no of records in PreviewOverlay

Posted: Wed Nov 23, 2016 12:12 am
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


Re: Set max no of records in PreviewOverlay

Posted: Wed Nov 23, 2016 9:19 am
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.


Re: Set max no of records in PreviewOverlay

Posted: Wed Nov 23, 2016 3:07 pm
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


Re: Set max no of records in PreviewOverlay

Posted: Wed Nov 23, 2016 3:36 pm
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";
}


Re: Set max no of records in PreviewOverlay

Posted: Sun May 14, 2017 1:53 pm
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`)");
    }
}

}