Vue UI Components Documentation
The Vue DockPanel allows the creation of dock layouts. This guide adds the Vue DockPanel (jqxDockPanel) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxdockpanel.vue In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxDockPanel from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxdockpanel.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Dock Panel demo as a Single-File Component:
<template>
<div style="width: 300px; height: 600px; font-size: 13px; font-family: Verdana">
<JqxDockPanel ref="DockPanel" :width="300" :height="210">
<div ref="first" dock="left" style="background: #486974">First Div</div>
<div ref="second" dock="top" style="height: 100px; background: #368ba7">Second Div</div>
<div ref="third" dock="right" style="background: #df7169">Third Div</div>
<div ref="fourth" style="background: #a73654">Fourth Div</div>
</JqxDockPanel>
<br />
<div>Layout Types:</div>
<div @click="clickOnLayout($event)">
<img
title="click to apply a new layout"
alt="layout types"
src="https://www.jqwidgets.com/vue/images/LayoutTypes.png"
/>
</div>
<br />
<div>Spiral:</div>
<JqxDockPanel ref="DockPanel2" :width="300" :height="210" :lastchildfill="false">
<div dock="left" style="background: #486974; width: 20px">1</div>
<div dock="top" style="background: #368ba7; height: 20px">2</div>
<div dock="right" style="background: #df7169; width: 20px">3</div>
<div dock="bottom" style="background: #a73654; height: 20px">4</div>
</JqxDockPanel>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxDockPanel from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxdockpanel.vue';
const first = ref(null);
const second = ref(null);
const third = ref(null);
const fourth = ref(null);
const DockPanel = ref(null);
const DockPanel2 = ref(null);
function layoutOnClick(event) {
let layoutsLength = 4;
let firstElement = first.value;
let secondElement = second.value;
let thirdElement = third.value;
let fourthElement = fourth.value;
let position = parseInt(event.clientX) - parseInt(event.target.offsetLeft);
if (position < 55) {
firstElement.setAttribute('dock', 'bottom');
firstElement.style.height = '105px';
secondElement.setAttribute('dock', 'left');
secondElement.style.width = '100px';
thirdElement.setAttribute('dock', 'left');
thirdElement.style.width = '100px';
fourthElement.setAttribute('dock', 'left');
fourthElement.style.width = '100px';
} else if (position < 115) {
for (let i = 0; i < layoutsLength; i++) {
DockPanel.value.$el.firstChild.children[i].style.width = '100px';
}
firstElement.setAttribute('dock', 'left');
secondElement.setAttribute('dock', 'right');
thirdElement.setAttribute('dock', 'bottom');
thirdElement.style.height = '140px';
fourthElement.setAttribute('dock', 'top');
fourthElement.style.height = '70px';
} else if (position < 175) {
for (let i = 0; i < layoutsLength; i++) {
DockPanel.value.$el.firstChild.children[i].style.width = '150px';
}
firstElement.setAttribute('dock', 'left');
secondElement.setAttribute('dock', 'left');
thirdElement.setAttribute('dock', 'left');
fourthElement.setAttribute('dock', 'left');
} else if (position < 235) {
for (let i = 0; i < layoutsLength; i++) {
DockPanel.value.$el.firstChild.children[i].style.height = '70px';
}
firstElement.setAttribute('dock', 'top');
secondElement.setAttribute('dock', 'top');
thirdElement.setAttribute('dock', 'top');
fourthElement.setAttribute('dock', 'top');
} else {
for (let i = 0; i < layoutsLength; i++) {
DockPanel.value.$el.firstChild.children[i].style.width = '100px';
}
firstElement.setAttribute('dock', 'left');
secondElement.setAttribute('dock', 'left');
thirdElement.setAttribute('dock', 'left');
fourthElement.setAttribute('dock', 'left');
}
}
function clickOnLayout(event) {
layoutOnClick(event);
DockPanel.value.refresh();
}
onMounted(() => {
DockPanel.value.$el.style.color = 'white';
DockPanel2.value.$el.style.color = 'white';
});
</script>
<style></style>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, layout: Occurs when the layout is performed.
<script setup>
function onLayout(event) {
console.log(event.args);
}
</script>
<template>
<JqxDockPanel @layout="onLayout" />
</template>
Call methods through a template ref. For example, refresh: Refreshes the DockPanel.
<script setup>
import { ref, onMounted } from 'vue';
const myDockPanel = ref(null);
onMounted(() => {
myDockPanel.value.refresh();
});
</script>
<template>
<JqxDockPanel ref="myDockPanel" />
</template>
Every component also has setOptions({ … }) and getOptions('name').