11<template >
2- <DxDataGrid
3- :data-source =" dataSource"
4- :columns =" columns"
5- :show-borders =" true"
2+ <div class =" employees" :class =" {
3+ 'employees--forth': pageSize === 4,
4+ 'employees--six': pageSize === 6,
5+ }" >
6+ <div class =" employees__card" v-for =" employee in pageEmployees" >
7+ <div class =" employees__img-wrapper" >
8+ <img class =" employees__img"
9+ :src =" employee.Picture"
10+ :alt =" employee.FullName"
11+ />
12+ </div >
13+ <div class =" employees__info" >
14+ <div class =" employees__info-row" >
15+ <span class =" employees__info-label" >Full Name:</span >
16+ <span class =" employees__info-value" >{{ employee.FullName }}</span >
17+ </div >
18+ <div class =" employees__info-row" >
19+ <span class =" employees__info-label" >Position:</span >
20+ <span class =" employees__info-value" >{{ employee.Title }}</span >
21+ </div >
22+ <div class =" employees__info-row" >
23+ <span class =" employees__info-label" >Phone:</span >
24+ <span class =" employees__info-value" >{{ employee.MobilePhone }}</span >
25+ </div >
26+ </div >
27+ </div >
28+ </div >
29+
30+ <DxPagination
31+ :show-info =" showInfo"
32+ :show-navigation-buttons =" showPageSizeSelector"
33+ :allowed-page-sizes =" pageSizes"
34+ v-model:page-index =" pageIndex"
35+ v-model:page-size =" pageSize"
36+ :item-count =" itemCount"
637 />
738</template >
8- <script >
9-
10- import DxDataGrid from ' devextreme-vue/data-grid' ;
11- import { customers } from ' ./data.js' ;
12-
13- export default {
14- components: {
15- DxDataGrid,
16- },
17- data () {
18- return {
19- dataSource: customers,
20- columns: [' CompanyName' , ' City' , ' State' , ' Phone' , ' Fax' ],
21- };
22- },
23- };
39+
40+ <script setup lang="ts">
41+ import { computed , ref } from ' vue' ;
42+ import DxPagination from ' devextreme-vue/pagination' ;
43+ import { employees } from ' ./data.ts' ;
44+
45+ const getPageEmployees = (pageIndex , pageSize ) => {
46+ return employees .slice ((pageIndex - 1 ) * pageSize , pageIndex * pageSize );
47+ }
48+
49+ const pageSizes = [4 , 6 ];
50+ const showInfo = true ;
51+ const showPageSizeSelector = true ;
52+ const pageIndex = ref (1 );
53+ const pageSize = ref (4 );
54+ const itemCount = employees .length ;
55+ const pageEmployees = computed (() => getPageEmployees (pageIndex .value , pageSize .value ));
2456 </script >
57+
58+ <style >
59+ body {
60+ overflow-x : hidden ;
61+ }
62+
63+ .demo-container {
64+ display : flex ;
65+ flex-direction : column ;
66+ align-items : center ;
67+ }
68+
69+ .container {
70+ min-width : 720px ;
71+ width : 100% ;
72+ }
73+
74+ .employees {
75+ display : flex ;
76+ flex-wrap : wrap ;
77+ gap : 16px ;
78+ min-height : 644px ;
79+ padding-bottom : 24px ;
80+ }
81+
82+ .employees__card {
83+ width : 100% ;
84+ max-height : 312px ;
85+ align-self : stretch ;
86+ overflow : hidden ;
87+ border : var (--dx-border-width ) solid var (--dx-color-border );
88+ border-radius : var (--dx-border-radius );
89+ background-color : var (--dx-component-color-bg );
90+ }
91+
92+ .employees.employees--forth .employees__card {
93+ min-width : 250px ;
94+ width : 390px ;
95+ flex-basis : calc (50% - 10px );
96+ }
97+
98+ .employees.employees--six .employees__card {
99+ flex-basis : calc (33.3% - 12.5px );
100+ }
101+
102+ .employees__img-wrapper {
103+ height : 180px ;
104+ position : relative ;
105+ overflow : hidden ;
106+ border-bottom : var (--dx-border-width ) solid var (--dx-color-border );
107+ background-color : #fff ;
108+ }
109+
110+ .employees__img {
111+ display : block ;
112+ height : 220px ;
113+ position : absolute ;
114+ content : " " ;
115+ left : 50% ;
116+ top : 0 ;
117+ transform : translateX (-50% );
118+ }
119+
120+ .employees__info {
121+ padding : 24px ;
122+ }
123+
124+ .employees__info-row {
125+ margin-bottom : 8px ;
126+ text-wrap : nowrap ;
127+ }
128+
129+ .employees__info-label {
130+ display : inline-block ;
131+ font-weight : 600 ;
132+ vertical-align : middle ;
133+ }
134+
135+ .employees.employees--forth .employees__info-label {
136+ width : 160px ;
137+ }
138+
139+ .employees.employees--six .employees__info-label {
140+ width : 80px ;
141+ }
142+
143+ .employees__info-value {
144+ display : inline-block ;
145+ text-wrap : nowrap ;
146+ text-overflow : ellipsis ;
147+ vertical-align : middle ;
148+ overflow : hidden ;
149+ white-space :nowrap
150+ }
151+
152+ .employees.employees--forth .employees__info-value {
153+ max-width : 180px ;
154+ }
155+
156+ .employees.employees--six .employees__info-value {
157+ max-width : 120px ;
158+ }
159+ </style >
0 commit comments