Loading...
Loading...
Compare original and translation side by side
import React, { useRef } from 'react';
import { DashboardLayoutComponent } from '@syncfusion/ej2-react-layouts';
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-layouts/styles/tailwind3.css';
function Dashboard() {
const dashboardRef = useRef<DashboardLayoutComponent>(null);
const panels = [
{
id: 'sales',
header: 'Sales',
content: '<div style="padding: 20px;">Sales data</div>',
row: 0,
col: 0,
sizeX: 2,
sizeY: 2
},
{
id: 'users',
header: 'Users',
content: '<div style="padding: 20px;">User analytics</div>',
row: 0,
col: 2,
sizeX: 2,
sizeY: 2
},
{
id: 'reports',
header: 'Reports',
content: '<div style="padding: 20px;">Report metrics</div>',
row: 2,
col: 0,
sizeX: 4,
sizeY: 1
}
];
return (
<div style={{ padding: '20px' }}>
<h1>Dashboard</h1>
<DashboardLayoutComponent
ref={dashboardRef}
id='dashboard'
columns={5}
cellSpacing={[10, 10]}
panels={panels}
allowDragging={true}
allowResizing={true}
allowFloating={true}
enablePersistence={true}
>
</DashboardLayoutComponent>
</div>
);
}
export default Dashboard;import React, { useRef } from 'react';
import { DashboardLayoutComponent } from '@syncfusion/ej2-react-layouts';
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-layouts/styles/tailwind3.css';
function Dashboard() {
const dashboardRef = useRef<DashboardLayoutComponent>(null);
const panels = [
{
id: 'sales',
header: 'Sales',
content: '<div style="padding: 20px;">Sales data</div>',
row: 0,
col: 0,
sizeX: 2,
sizeY: 2
},
{
id: 'users',
header: 'Users',
content: '<div style="padding: 20px;">User analytics</div>',
row: 0,
col: 2,
sizeX: 2,
sizeY: 2
},
{
id: 'reports',
header: 'Reports',
content: '<div style="padding: 20px;">Report metrics</div>',
row: 2,
col: 0,
sizeX: 4,
sizeY: 1
}
];
return (
<div style={{ padding: '20px' }}>
<h1>Dashboard</h1>
<DashboardLayoutComponent
ref={dashboardRef}
id='dashboard'
columns={5}
cellSpacing={[10, 10]}
panels={panels}
allowDragging={true}
allowResizing={true}
allowFloating={true}
enablePersistence={true}
>
</DashboardLayoutComponent>
</div>
);
}
export default Dashboard;<DashboardLayoutComponent
id='responsive-dashboard'
columns={5}
mediaQuery='max-width:768px' // Single column on tablets/mobile
cellSpacing={[10, 10]}
allowDragging={true}
allowResizing={true}
panels={panels}
>
</DashboardLayoutComponent>responsive-design.md<DashboardLayoutComponent
id='responsive-dashboard'
columns={5}
mediaQuery='max-width:768px' // 平板/移动端下为单列布局
cellSpacing={[10, 10]}
allowDragging={true}
allowResizing={true}
panels={panels}
>
</DashboardLayoutComponent>responsive-design.mdconst handleSaveLayout = () => {
const layout = dashboardRef.current?.serialize();
localStorage.setItem('userDashboard', JSON.stringify(layout));
};
const handleRestoreLayout = () => {
const saved = localStorage.getItem('userDashboard');
if (saved) {
const layout = JSON.parse(saved);
dashboardRef.current?.removeAll();
layout.forEach(panel => {
dashboardRef.current?.addPanel(panel);
});
}
};state-persistence.mdconst handleSaveLayout = () => {
const layout = dashboardRef.current?.serialize();
localStorage.setItem('userDashboard', JSON.stringify(layout));
};
const handleRestoreLayout = () => {
const saved = localStorage.getItem('userDashboard');
if (saved) {
const layout = JSON.parse(saved);
dashboardRef.current?.removeAll();
layout.forEach(panel => {
dashboardRef.current?.addPanel(panel);
});
}
};state-persistence.mdconst handleAddPanel = () => {
dashboardRef.current?.addPanel({
id: `panel-${Date.now()}`,
header: 'New Panel',
content: 'Panel content',
row: 0,
col: 0,
sizeX: 2,
sizeY: 1
});
};
const handleRemovePanel = (panelId: string) => {
dashboardRef.current?.removePanel(panelId);
};methods-reference.mdconst handleAddPanel = () => {
dashboardRef.current?.addPanel({
id: `panel-${Date.now()}`,
header: 'New Panel',
content: 'Panel content',
row: 0,
col: 0,
sizeX: 2,
sizeY: 1
});
};
const handleRemovePanel = (panelId: string) => {
dashboardRef.current?.removePanel(panelId);
};methods-reference.mdconst constrainedPanels = [
{
id: 'fixed-panel',
header: 'Fixed Size',
row: 0,
col: 0,
sizeX: 2,
sizeY: 1,
minSizeX: 2, // Cannot shrink
maxSizeX: 2, // Cannot expand
minSizeY: 1,
maxSizeY: 1
},
{
id: 'flexible-panel',
header: 'Flexible',
row: 0,
col: 2,
sizeX: 2,
sizeY: 1,
minSizeX: 1, // Can shrink to 1 cell
maxSizeX: 4 // Can expand to 4 cells
}
];cell-configuration.mdresizing-floating.mdconst constrainedPanels = [
{
id: 'fixed-panel',
header: 'Fixed Size',
row: 0,
col: 0,
sizeX: 2,
sizeY: 1,
minSizeX: 2, // 不可缩小
maxSizeX: 2, // 不可放大
minSizeY: 1,
maxSizeY: 1
},
{
id: 'flexible-panel',
header: 'Flexible',
row: 0,
col: 2,
sizeX: 2,
sizeY: 1,
minSizeX: 1, // 最小可缩小到1个单元格
maxSizeX: 4 // 最大可放大到4个单元格
}
];cell-configuration.mdresizing-floating.mdconst handleChange = (args: ChangeEventArgs) => {
console.log('Panels added:', args.addedPanels);
console.log('Panels removed:', args.removedPanels);
console.log('Panels position changed:', args.changedPanels);
console.log('User interaction:', args.isInteracted);
};
<DashboardLayoutComponent
panels={panels}
change={handleChange}
>
</DashboardLayoutComponent>events-reference.mdconst handleChange = (args: ChangeEventArgs) => {
console.log('Panels added:', args.addedPanels);
console.log('Panels removed:', args.removedPanels);
console.log('Panels position changed:', args.changedPanels);
console.log('User interaction:', args.isInteracted);
};
<DashboardLayoutComponent
panels={panels}
change={handleChange}
>
</DashboardLayoutComponent>events-reference.mdcell-configuration.mdcell-configuration.mdpanel-templates.mddragging-behavior.mdresizing-floating.mdresizing-floating.mdstate-persistence.mdresponsive-design.mddragging-behavior.mdresizing-floating.mdstyling-customization.mdcell-configuration.mdcell-configuration.mdpanel-templates.mddragging-behavior.mdresizing-floating.mdresizing-floating.mdstate-persistence.mdresponsive-design.mddragging-behavior.mdresizing-floating.mdstyling-customization.mdcore-functionality.mdcore-functionality.mdcore-functionality.mdcore-functionality.mddragging-behavior.mdresizing-floating.mdstate-persistence.mdcore-functionality.mdcore-functionality.mdcore-functionality.mdcore-functionality.mddragging-behavior.mdresizing-floating.mdstate-persistence.mddragging-behavior.mdresizing-floating.mdevents-reference.mddragging-behavior.mdresizing-floating.mdevents-reference.mdinterface PanelModel {
id: string; // Unique identifier (required)
row: number; // Row position (required)
col: number; // Column position (required)
sizeX: number; // Width in cells (default: 1)
sizeY: number; // Height in cells (default: 1)
header?: string | HTMLElement | Function;
content?: string | HTMLElement | Function;
cssClass?: string; // Custom CSS classes
enabled?: boolean; // Enable/disable (default: true)
minSizeX?: number; // Minimum width (default: 1)
minSizeY?: number; // Minimum height (default: 1)
maxSizeX?: number; // Maximum width
maxSizeY?: number; // Maximum height
zIndex?: number; // Stacking order
}interface PanelModel {
id: string; // 唯一标识符(必填)
row: number; // 行位置(必填)
col: number; // 列位置(必填)
sizeX: number; // 宽度(单元格数,默认:1)
sizeY: number; // 高度(单元格数,默认:1)
header?: string | HTMLElement | Function;
content?: string | HTMLElement | Function;
cssClass?: string; // 自定义CSS类
enabled?: boolean; // 启用/禁用(默认:true)
minSizeX?: number; // 最小宽度(默认:1)
minSizeY?: number; // 最小高度(默认:1)
maxSizeX?: number; // 最大宽度
maxSizeY?: number; // 最大高度
zIndex?: number; // 堆叠顺序
}| Task | Read This Documentation |
|---|---|
| Get Started | getting-started.md - Installation, setup, themes |
| Learn Panel Management | core-functionality.md - Create, update, remove panels |
| Customize Panel Content | panel-templates.md - Headers, templates, component embedding |
| Make It Draggable | dragging-behavior.md - Drag events, collision, custom handles |
| Make It Resizable | resizing-floating.md - Resize handles, constraints, floating |
| Configure Grid System | cell-configuration.md - Columns, spacing, aspect ratio, responsive grids |
| Make It Responsive | responsive-design.md - Breakpoints, mobile, touch optimization |
| Save User Layouts | state-persistence.md - serialize(), localStorage, API, Redux, Context |
| Style & Theme | styling-customization.md - CSS selectors, themes, responsive styling |
| Make It Accessible | accessibility-wcag.md - WCAG 2.2, WAI-ARIA, screen readers, RTL |
| API Reference | properties-reference.md, methods-reference.md, events-reference.md |
| Advanced Patterns | advanced-features.md - Custom integrations, performance optimization |
| 任务 | 参考文档 |
|---|---|
| 快速上手 | getting-started.md - 安装、配置、主题 |
| 学习面板管理 | core-functionality.md - 创建、更新、删除面板 |
| 自定义面板内容 | panel-templates.md - 头部、模板、组件嵌入 |
| 实现拖拽功能 | dragging-behavior.md - 拖拽事件、碰撞、自定义手柄 |
| 实现尺寸调整 | resizing-floating.md - 尺寸调整手柄、约束、浮动 |
| 配置网格系统 | cell-configuration.md - 列数、间距、宽高比、响应式网格 |
| 实现响应式适配 | responsive-design.md - 断点、移动端、触摸优化 |
| 保存用户布局 | state-persistence.md - serialize()、localStorage、API、Redux、Context |
| 样式与主题 | styling-customization.md - CSS选择器、主题、响应式样式 |
| 实现无障碍支持 | accessibility-wcag.md - WCAG 2.2、WAI-ARIA、屏幕阅读器、RTL |
| API参考 | properties-reference.md、methods-reference.md、events-reference.md |
| 高级模式 | advanced-features.md - 自定义集成、性能优化 |