Pull down to refresh...
Release to refresh...
Refreshing...
-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
- Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Related Demos:
Your search did not match any results.
Loading...
Tab Panel - Tab Drag & Drop
This demo illustrates how you can allow end-users to reorder, add, and remove tabs within the DevExtreme TabPanel component.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
x
@model IEnumerable<DevExtreme.MVC.Demos.Models.DataGrid.Employee>
<div id="container">
@(Html.DevExtreme().Button()
.ID("addButton")
.Text("Add Tab")
.Icon("add")
.Type(ButtonType.Default)
.OnClick("addButtonHandler"))
</div>
@(Html.DevExtreme().Sortable()
.MoveItemOnDrop(true)
.Filter(".dx-tab")
.ItemOrientation(Orientation.Horizontal)
.DragDirection(DragDirection.Horizontal)
.OnReorder("onReorder")
.Content(@<text>@Html.Partial("_SortableTabPanel")</text>)
)
<script>
var tabPanel;
var allEmployees = @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model.Take(9)));
function onInitialized(e) {
tabPanel = e.component;
}
function onReorder(e) {
var tabPanelItems = tabPanel.option("items");
var itemData = tabPanelItems.splice(e.fromIndex, 1)[0];
tabPanelItems.splice(e.toIndex, 0, itemData);
tabPanel.option("items", tabPanelItems);
tabPanel.option("selectedIndex", e.toIndex);
}
function addButtonHandler() {
var tabPanelItems = tabPanel.option("items")
var newItem = allEmployees.filter(function (employee) { return tabPanelItems.map(function (item) { return item.ID }).indexOf(employee.ID) === -1 })[0];
tabPanelItems.push(newItem);
tabPanel.option("items", tabPanelItems);
tabPanel.option("selectedItem", newItem);
updateButtonsState(tabPanelItems);
}
function closeButtonHandler(itemData) {
var tabPanelItems = tabPanel.option("items").slice();
var index = tabPanelItems.indexOf(itemData);
tabPanelItems.splice(index, 1);
if (index >= tabPanelItems.length && index > 0) tabPanel.option("selectedIndex", index - 1);
tabPanel.option("items", tabPanelItems);
updateButtonsState(tabPanelItems);
}
function updateButtonsState(items) {
$("#addButton").dxButton("instance").option("disabled", items.length === allEmployees.length);
if (items.length <=2 ) tabPanel.repaint();
}
</script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Reorder tabs
Wrap the TabPanel into the Sortable component and set the following properties as needed:
-
filter
Specify a CSS selector to indicate draggable items. This demo sets filter to.dx-tab
. -
itemOrientation
Set this property to "horizontal". When a user drags a tab, remaining items move left and right to designate the drop target. -
onDragStart and onReorder
Implement these handlers to configure drag and drop logic and modify the dataSource after the tabs are reordered.
Add or remove tabs
This demo adds and removes tabs in the following two functions:
addButtonHandler
- a click handler for the "Add Tab" button.closeButtonHandler
- a click handler for a tab's Close icon. The demo uses the itemTitleTemplate property to display this icon.
Both handlers modify the TabPanel's dataSource.