Vue UI Components Documentation

Vue Expander Component

The Expander component for Vue has header and content sections (like tabs).

Prerequisites

Refer to Vue Getting Started before you start with this help topic.

Configuration

After you have created your App.vue file, here is how you should structure it:

The Expander component for Vue requires the following import:

import JqxExpander from "jqwidgets-scripts/jqwidgets-vue/vue_jqxexpander.vue";

Add the jqxExpander component to the components section of the the Vue class:

 components: {
JqxExpander
},

Template

The App.vue has a <template> structural tag where we determine the application structure. There we will also set the tags for the new components - <JqxExpander/>

<template>
<JqxExpander :width="width" :toggleMode="toggleMode">
<div>Early History of the Internet</div>
<div>
<ul>
<li>1961 First packet-switching papers</li>
<li>1966 Merit Network founded</li>
<li>1966 ARPANET planning starts</li>
<li>1969 ARPANET carries its first packets</li>
<li>1970 Mark I network at NPL (UK)</li>
<li>1970 Network Information Center (NIC)</li>
<li>1971 Merit Networks packet-switched network operational</li>
<li>1971 Tymnet packet-switched network</li>
<li>1972 Internet Assigned Numbers Authority (IANA) established</li>
<li>1973 CYCLADES network demonstrated</li>
<li>1974 Telenet packet-switched network</li>
<li>1976 X.25 protocol approved</li>
<li>1979 Internet Activities Board (IAB)</li>
<li>1980 USENET news using UUCP</li>
<li>1980 Ethernet standard introduced</li>
<li>1981 BITNET established</li>
</ul>
</div>
</JqxExpander>
</template>

Properties

The properties of the <JqxExpander/> component are defined in the data member of the Vue class. We should put them in the return object of the data function:

data: function () {
return {
width: 350,
toggleMode: 'dblclick'
}
}

Events

The events in Vue are set as an attribute with @ prefix, for example:

<JqxExpander @expanded="onExpanded()" 
:width="width" :toggleMode="toggleMode">
<div>Early History of the Internet</div>
<div>
<ul>
<li>1961 First packet-switching papers</li>
<li>1966 Merit Network founded</li>
<li>1966 ARPANET planning starts</li>
<li>1969 ARPANET carries its first packets</li>
<li>1970 Mark I network at NPL (UK)</li>
<li>1970 Network Information Center (NIC)</li>
<li>1971 Merit Networks packet-switched network operational</li>
<li>1971 Tymnet packet-switched network</li>
<li>1972 Internet Assigned Numbers Authority (IANA) established</li>
<li>1973 CYCLADES network demonstrated</li>
<li>1974 Telenet packet-switched network</li>
<li>1976 X.25 protocol approved</li>
<li>1979 Internet Activities Board (IAB)</li>
<li>1980 USENET news using UUCP</li>
<li>1980 Ethernet standard introduced</li>
<li>1981 BITNET established</li>
</ul>
</div>
</JqxExpander>

All events that are bound to a component are implemented in the methods member of the Vue class.

methods: {
onExpanded: function () {
// Do something...
}
}

Methods

To use a component's method we should have its reference. In Vue we refer to a component by the special $refs property. Before that we need to add the desired name reference to that component:

<JqxExpander ref="expander"></JqxExpander>

Here how you can use a component's method:

this.$refs.expander.refresh();

If we want to add additional methods we should also implement them in the methods member.

In case we need to do some precalculation or something else before the components are rendered, we should use the beforeCreate member. It depends on the case.

If you have followed the above steps, you App.vue file would look like this:

App.vue:

Expander Example

Run Code