Import
-import Panel from 'primevue/panel';
+import OrderList from 'primevue/orderlist';
Getting Started
- Panel is a container component that accepts content as its children.
+ OrderList requires an array as its value bound with the v-model directive and a template for its content.
+ Header of the component is defined with the "header" template and to define the content of an item in the list a named templated called "item" needs to be defined which gets the
+ item and the index via slotProps.
+
-<Panel header="Godfather I">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
-</Panel>
-
-
- Custom Header
- Header of the panel is either defined with the header property or the header template.
-
-<Panel>
+
+<OrderList v-model="cars" header="List of Cars" listStyle="height:auto" dataKey="vin">
<template #header>
- Header Content
+ List of Cars
</template>
- Content
-</Panel>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>{{slotProps.item.brand}} - {{slotProps.item.year}} - {{slotProps.item.color}}</div>
+ </div>
+ </template>
+</OrderList>
+
- Toggleable
- Content of the panel can be expanded and collapsed using toggleable option.
-
-<Panel header="Godfather I" :toggleable="true">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
-</Panel>
-
-
- To control the initial state of the toggleable panel, use the collapsed property.
-
-<Panel header="Header Text" :toggleable="true" :collapsed="true">
- Content
-</Panel>
-
+ Selection
+ In case you'd need to access the selected items in the list, define a binding to the selection property with the sync operator so that
+ it gets updated when the user makes a selection. Since it is two-way binding enabled, your changes to the selection will be reflected as well. Note that
+ this is optional and only necessary when you need to access the selection.
Use the sync operator to enable two-way binding.
-<button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically</button>
-<Panel header="Header Text" :toggleable="true" :collapsed.sync="isCollapsed">
- Content
-</Panel>
+
+<OrderList v-model="cars" header="List of Cars" listStyle="height:auto" dataKey="vin" :dragdrop="true">
+ <template #header>
+ List of Cars
+ </template>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>{{slotProps.item.brand}} - {{slotProps.item.year}} - {{slotProps.item.color}}</div>
+ </div>
+ </template>
+</OrderList>
+
+ DataKey
+ It is recommended to provide the name of the field that uniquely identifies the a record in the data via the dataKey property for better performance.
+
Properties
Any attribute such as style and class are passed to the main container element. Following are the additional properties to configure the component.
@@ -70,22 +68,37 @@ import Panel from 'primevue/panel';
- header |
+ value |
+ array |
+ null |
+ Value of the component. |
+
+
+ selection |
+ any |
+ null |
+ Selected items in the list. |
+
+
+ metaKeySelection |
+ boolean |
+ true |
+ Defines whether metaKey is requred or not for the selection.
+ When true metaKey needs to be pressed to select or unselect an item and
+ when set to false selection of each item
+ can be toggled individually. On touch enabled devices, metaKeySelection is turned off automatically. |
+
+
+ dataKey |
string |
null |
- Header text of the panel. |
+ Name of the field that uniquely identifies the a record in the data. |
- toggleable |
- boolean |
+ listStyle |
+ object |
null |
- Defines if content of panel can be expanded and collapsed. |
-
-
- collapsed |
- boolean |
- null |
- Defines the initial state of panel content. |
+ Inline style of the the list element. |
@@ -103,11 +116,12 @@ import Panel from 'primevue/panel';
- toggle |
+ reorder |
event.originalEvent: browser event
- event.value: collapsed state as a boolean
+ event.value: Ordered list
+ event.direction: Direction of the change; "up", "down", "bottom", "top"
|
- Callback to invoke when a tab toggle. |
+ Callback to invoke when the list is reordered. |
@@ -125,24 +139,16 @@ import Panel from 'primevue/panel';
- p-panel |
+ p-orderlist |
Container element. |
- p-panel-titlebar |
- Header section. |
+ p-orderlist-list |
+ List container. |
- p-panel-title |
- Title text of panel. |
-
-
- p-panel-titlebar-toggler |
- Toggle icon. |
-
-
- p-panel-content |
- Content of panel. |
+ p-orderlist-item |
+ An item in the list |
@@ -158,35 +164,60 @@ import Panel from 'primevue/panel';
-<template>
- <div>
- <div class="content-section introduction">
- <div class="feature-intro">
- <h1>Panel</h1>
- <p>Panel is a grouping component with the optional content toggle feature.</p>
- </div>
- </div>
-
- <div class="content-section implementation">
- <h3 class="first">Regular</h3>
- <Panel header="Godfather I">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
- </Panel>
-
- <h3>Toggleable</h3>
- <Panel header="Godfather I" :toggleable="true">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
- </Panel>
- </div>
- </div>
-</template>
+<OrderList v-model="cars" header="List of Cars" listStyle="height:auto" dataKey="vin">
+ <template #header>
+ List of Cars
+ </template>
+ <template #item="slotProps">
+ <div class="p-caritem">
+ <img :src="'demo/images/car/' + slotProps.item.brand + '.png'">
+ <div>{{slotProps.item.brand}} - {{slotProps.item.year}} - {{slotProps.item.color}}</div>
+ </div>
+ </template>
+</OrderList>
+
+
+
+import CarService from '../../service/CarService';
+
+export default {
+ data() {
+ return {
+ cars: null
+ }
+ },
+ carService: null,
+ created() {
+ this.carService = new CarService();
+ },
+ mounted() {
+ this.carService.getCarsSmall().then(data => this.cars = data.slice(0,5));
+ }
+}
+
+
+
+.p-caritem {
+ &:after {
+ content: "";
+ display: table;
+ clear: both;
+ }
+
+ img {
+ display:inline-block;
+ margin:2px 0 2px 2px;
+ width: 48px;
+ height: 48px;
+ }
+
+ div {
+ font-size:14px;
+ float:right;
+ margin: 16px 6px 0 0;
+ }
+}