Context menu, enable "Open" menu item on pdf file
As mentioned in the subject, I only need to enable context menu "Open" menu item, when it is a pdf file. (No need of opening the pdf file) Currently it is enable only for folders and image types.
I tried with
$fileExplorer->menuBeforeOpen('beforeContextMenuOpen')
but I couldn't find a solution. Any help would be appreciable.
SIGN IN To post a reply.
5 Replies
1 reply marked as answer
MK
Muthukrishnan Kandasamy
Syncfusion Team
December 28, 2020 10:59 AM UTC
Hi Shanaka,
Greetings from Syncfusion support.
We have validated your requirement in File Explorer control. We can enable/disable the context menu item in the File Explorer control by using method enableMenuItem. We have prepared sample to meet your requirement, in this sample we have used the MenuOpen event for enabling the Open menu item. Please refer the below code block.
|
div class="cols-sample-area">
<?php
$fileexplorer=new EJ\FileExplorer('default');
echo $fileexplorer
->path('FileExplorerPHP/FileBrowser/')
->ajaxAction('EJ/Services/FileExplorer')
->ajaxDataType('jsonp')
->menuOpen('onMenuOpen')
->enableThumbnailCompress(true)
->width('100%')
->isResponsive(true)
->render();
?>
</div>
<script>
function onMenuOpen(args){
this.enableMenuItem("Open");
}
</script>
|
We have prepared sample application for your convenience, which can be downloaded from the below link.
|
Description |
Link |
|
Getting started |
|
|
Dependencies |
|
|
Live demo |
|
|
API reference |
Please let us know, if you need any further assistance.
Regards,
Muthukrishnan K
Marked as answer
SP
shanaka perera
December 28, 2020 01:29 PM UTC
Hi Muthukrishnan,
Thank you for the reply. Please let me know if there is a way to check whether the contextMenu popup element is a pdf document or not. Because I want to perform enabling this "Open" menuItem only if it is generated on top of a pdf document.
Example
function onMenuOpen(args) {
if (args.something == 'pdf') { // if the file is pdf then enable Open menuItem
this.enableMenuItem("Open");
}
}
MK
Muthukrishnan Kandasamy
Syncfusion Team
December 29, 2020 06:44 AM UTC
Hi Shanaka,
Thanks for the update.
We have validated your requirement in PHP File Explorer control. We can achieve your requirement by checking whether the selected item is pdf or not. Please refer to the below code block.
|
function onMenuOpen(args){
if(this._selectedItems[0] && this._selectedItems[0].includes(".pdf")){
this.enableMenuItem("Open");
}
}
|
Please let us know, if you need any further assistance.
Regards,
Muthukrishnan K
SP
shanaka perera
January 1, 2021 05:11 AM UTC
Hi Muthukrishnan,
Thank you for your reply and what you have suggested is working fine.
KR
Keerthana Rajendran
Syncfusion Team
January 4, 2021 03:37 AM UTC
Hi Shanaka,
Most Welcome. We are happy to hear that your problem has been resolved with the provided suggestion. Please let us know, if you need any further assistance.
Regards,
Keerthana.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
- Marked answer
-
SP shanaka perera
- Dec 26, 2020 01:17 PM UTC
- Jan 4, 2021 03:37 AM UTC