-
AI-powered Extensions
-
Data Grid
-
Tree List
-
Chat
-
HTML Editor
-
Form
-
-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
- AI Assistant
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Action Sheet
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
-
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
Vue File Manager - Toolbar and Context Menu
The FileManager component provides the following UI customization properties:
- The toolbar property specifies the toolbar's visibility and available commands.
- The contextMenu property specifies the context menu's availability and its commands.
The toolbar and context menu support context-invariant and context-sensitive items that can be visible or hidden depending on user action.
Backend API
<template>
<DxFileManager
ref="fileManager"
:file-system-provider="fileItems"
@context-menu-item-click="onItemClick"
:height="450"
>
<DxPermissions
:create="true"
:copy="true"
:move="true"
:delete="true"
:rename="true"
/>
<DxItemView
:show-parent-folder="false"
>
<DxDetails>
<DxColumn data-field="thumbnail"/>
<DxColumn data-field="name"/>
<DxColumn
data-field="category"
caption="Category"
:width="95"
/>
<DxColumn data-field="dateModified"/>
<DxColumn data-field="size"/>
</DxDetails>
</DxItemView>
<DxToolbar>
<DxItem
name="showNavPane"
:visible="true"
/>
<DxItem name="separator"/>
<DxItem name="create"/>
<DxItem
widget="dxMenu"
location="before"
:options="newFileMenuOptions"
/>
<DxItem name="refresh"/>
<DxItem
name="separator"
location="after"
/>
<DxItem name="switchView"/>
<DxFileSelectionItem name="rename"/>
<DxFileSelectionItem name="separator"/>
<DxFileSelectionItem name="delete"/>
<DxFileSelectionItem name="separator"/>
<DxFileSelectionItem
widget="dxMenu"
location="before"
:options="changeCategoryMenuOptions"
/>
<DxFileSelectionItem name="refresh"/>
<DxFileSelectionItem name="clearSelection"/>
</DxToolbar>
<DxContextMenu>
<DxItem name="create"/>
<DxItem
text="Create new file"
icon="plus"
>
<DxItem text="Text Document"/>
<DxItem text="RTF Document"/>
<DxItem text="Spreadsheet"/>
</DxItem>
<DxItem
name="rename"
:begin-group="true"
/>
<DxItem name="delete"/>
<DxItem
text="Category"
icon="tags"
:begin-group="true"
>
<DxItem text="Work"/>
<DxItem text="Important"/>
<DxItem text="Home"/>
<DxItem text="None"/>
</DxItem>
</DxContextMenu>
</DxFileManager>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import {
DxFileManager, DxPermissions, DxToolbar, DxContextMenu, DxItem,
DxFileSelectionItem, DxItemView, DxDetails, DxColumn, type DxFileManagerTypes,
} from 'devextreme-vue/file-manager';
import FileSystemItem from 'devextreme/file_management/file_system_item';
import { fileItems, getItemInfo } from './data.ts';
const newFileMenuOptions = getNewFileMenuOptions();
const changeCategoryMenuOptions = getChangeCategoryMenuOptions();
const fileManager = ref();
function onItemClick(
{ itemData, viewArea, fileSystemItem }: DxFileManagerTypes.ContextMenuItemClickEvent,
) {
let updated = false;
const { extension, category } = getItemInfo(itemData.text);
if (extension) {
updated = createFile(extension, fileSystemItem);
} else if (category !== undefined && fileSystemItem) {
updated = updateCategory(category, fileSystemItem, viewArea);
}
if (updated) {
fileManager.value.instance.refresh();
}
}
function createFile(
fileExtension: string,
directory: any = fileManager.value.instance.getCurrentDirectory(),
) {
const newItem = {
__KEY__: Date.now(),
name: `New file${fileExtension}`,
isDirectory: false,
size: 0,
};
if (!directory.isDirectory) {
return false;
}
let array: Record<string, unknown>[];
if (!directory.dataItem) {
array = fileItems;
} else {
array = directory.dataItem.items;
if (!array) {
array = [];
directory.dataItem.items = array;
}
}
array.push(newItem);
return true;
}
function updateCategory(newCategory: string, directory: FileSystemItem, viewArea: string) {
let items: FileSystemItem[] = [];
if (viewArea === 'navPane') {
items = [directory];
} else {
items = fileManager.value.instance.getSelectedItems();
}
items.forEach((item: FileSystemItem) => {
if (item.dataItem) {
item.dataItem.category = newCategory;
}
});
return items.length > 0;
}
function getNewFileMenuOptions() {
return {
items: [
{
text: 'Create new file',
icon: 'plus',
items: [
{
text: 'Text Document',
options: {
extension: '.txt',
},
},
{
text: 'RTF Document',
options: {
extension: '.rtf',
},
},
{
text: 'Spreadsheet',
options: {
extension: '.xls',
},
},
],
},
],
onItemClick,
};
}
function getChangeCategoryMenuOptions() {
return {
items: [
{
text: 'Category',
icon: 'tags',
items: [
{
text: 'Work',
options: {
category: 'Work',
},
},
{
text: 'Important',
options: {
category: 'Important',
},
},
{
text: 'Home',
options: {
category: 'Home',
},
},
{
text: 'None',
options: {
category: '',
},
},
],
},
],
onItemClick,
};
}
</script>
export const fileItems = [{
name: 'Documents',
isDirectory: true,
category: 'Work',
items: [{
name: 'Projects',
isDirectory: true,
category: 'Work',
items: [{
name: 'About.rtf',
isDirectory: false,
size: 1024,
}, {
name: 'Passwords.rtf',
isDirectory: false,
category: 'Important',
size: 2048,
}],
}, {
name: 'About.xml',
isDirectory: false,
size: 1024,
}, {
name: 'Managers.rtf',
isDirectory: false,
size: 2048,
}, {
name: 'ToDo.txt',
isDirectory: false,
size: 3072,
}],
}, {
name: 'Images',
isDirectory: true,
category: 'Home',
items: [{
name: 'logo.png',
isDirectory: false,
size: 20480,
}, {
name: 'banner.gif',
isDirectory: false,
size: 10240,
}],
}, {
name: 'System',
isDirectory: true,
category: 'Important',
items: [{
name: 'Employees.txt',
isDirectory: false,
category: 'Important',
size: 3072,
}, {
name: 'PasswordList.txt',
isDirectory: false,
category: 'Important',
size: 5120,
}],
}, {
name: 'Description.rtf',
isDirectory: false,
size: 1024,
}, {
name: 'Description.txt',
isDirectory: false,
size: 2048,
}];
const fileExtensions: Record<string, string> = {
'Text Document': '.txt',
'RTF Document': '.rtf',
Spreadsheet: '.xls',
};
const categories = ['Work', 'Important', 'Home', 'None'];
export function getItemInfo(name: string) {
const extension = fileExtensions[name];
const category = extension ?? categories.find((cat) => cat === name);
return {
extension,
category,
};
}
import { createApp } from 'vue';
import App from './App.vue';
createApp(App).mount('#app');
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="app">
<span v-if="false">Loading...</span>
</div>
</div>
<script src="bundles/vendor/vue.vendor.js"></script>
<script src="./bundle.js"></script>
</body>
</html>