Vue UI Components Documentation

Vue DropDownList Component

The DropDownList component for Vue contains a list of selectable items displayed in a drop-down.

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 DropDownList component for Vue requires the following import:


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


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 - <JqxDropDownList/>

<template>
<JqxDropDownList :width="200" :height="25"
:source="source" :selectedIndex="1">
</JqxDropDownList>
</template>

Properties

The properties of the <JqxDropDownList/> 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 {
source: [
'Affogato',
'Americano',
'Bicerin',
'Breve',
'Café Bombón',
'Café au lait',
'Caffé Corretto',
'Café Crema',
'Caffé Latte',
'Caffé macchiato',
'Café mélange',
'Coffee milk',
'Cafe mocha',
'Cappuccino',
'Carajillo',
'Cortado',
'Cuban espresso',
'Espresso',
'Eiskaffee',
'The Flat White',
'Frappuccino',
'Galao',
'Greek frappé coffee',
'Iced Coffee',
'Indian filter coffee',
'Instant coffee',
'Irish coffee',
'Liqueur coffee'
]
}
}

Events

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

<JqxDropDownList @select="onSelect($event)"
:width="200" :height="25"
:source="source" :selectedIndex="1">
</JqxDropDownList>

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


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:

<JqxDropDownList ref="dropdownlist"></JqxDropDownList>

Here how you can use a component's method:

this.$refs.dropdownlist.close();

methods: {
// Add here all used callbacks and/or events
onSelect: function () {
// Do something...
this.$refs.dropdownlist.close();
}
}

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:

<template>
<JqxDropDownList @select="onSelect($event)"
:width="200" :height="25"
:source="source" :selectedIndex="1">
</JqxDropDownList>
</template>
<script>
// Import the components that will be used
import JqxDropDownList from "jqwidgets-scripts/jqwidgets-vue/vue_jqxdropdownlist.vue";
export default {
components: {
// Adding imported widgets here
JqxDropDownList
},
data: function () {
// Define properties which will use in the widget
return {
source: [
'Affogato',
'Americano',
'Bicerin',
'Breve',
'Café Bombón',
'Café au lait',
'Caffé Corretto',
'Café Crema',
'Caffé Latte',
'Caffé macchiato',
'Café mélange',
'Coffee milk',
'Cafe mocha',
'Cappuccino',
'Carajillo',
'Cortado',
'Cuban espresso',
'Espresso',
'Eiskaffee',
'The Flat White',
'Frappuccino',
'Galao',
'Greek frappé coffee',
'Iced Coffee',
'Indian filter coffee',
'Instant coffee',
'Irish coffee',
'Liqueur coffee'
]
}
},
beforeCreate: function () {
// Add here any data where you want to transform before components be rendered
},
methods: {
methods: {
// Add here all used callbacks and/or events
onSelect: function () {
// Do something...
this.$refs.dropdownlist.close();
}
}
}
}
</script>
<style>
</style>

DropDownList Example

<template>
<JqxDropDownList :width="280" :height="30" :source="shirts" :selectedIndex="0" :itemHeight="90"
:filterable="true" :renderer="renderer" :selectionRenderer="selectionRenderer">
</JqxDropDownList>
</template>
<script>
import JqxDropDownList from "jqwidgets-scripts/jqwidgets-vue/vue_jqxdropdownlist.vue";
export default {
components: {
JqxDropDownList
},
data: function () {
return {
shirts: [
"2 sided dodgers\nbankrupt\nt shirt ash", "black retro\nrock band\nguitar controller",
"bright green\ngettin lucky\nin kentucky", "brown loading\nbar computer geek", "cool story bro",
"fear the beard", "honey badger\ndon t care", "misfits sf\ngiants white", "scott pilgrim\nred rock\nband"
]
}
},
beforeCreate: function () {
this.shirtFileNames = [
"2-sided-dodgers-bankrupt-t-shirt-ash", "black-retro-rock-band-guitar-controller",
"bright-green-gettin-lucky-in-kentucky", "brown-loading-bar-computer-geek", "cool-story-bro",
"fear-the-beard", "honey-badger-don-t-care", "misfits-sf-giants-white", "scott-pilgrim-red-rock-band"
];
},
methods: {
renderer: function (index, label, value) {
let datarecord = this.shirtFileNames[index];
let imgurl = 'images/t-shirts/' + datarecord.toLowerCase() + '.png';
let img = '<img height="70" width="70" src="' + imgurl + '"/>';
let table = '<table style="min-width: 130px;"><tr><td style="width: 80px;">' + img + '</td><td>' + label + '</td></tr></table>';
return table;
},
selectionRenderer: function (element, index, label, value) {
let text = label.replace(/\n/g, " ");
return '<span style="left: 4px; top: 6px; position: relative;">' + text + '</span>';
}
}
}
</script>
<style>
</style>

Run Code