반응형
Vuetify 데이터 테이블 작업 행
페이지당 행과 페이지 네비게이션을 왼쪽 정렬하여 같은 줄에 버튼을 둘 수 있습니까?
작업 행은 기본적으로 오른쪽에 정렬됩니다.하지만 네가 원하는 것을 이룰 수 있는 방법은 있어.사용자 지정 페이지 번호를 사용하여 현재 페이지를 숨길 수 있습니다.
<v-data-table
:headers="headers"
:items="desserts"
:search="search"
hide-actions
:pagination.sync="pagination"
>
데이터 테이블 뒤에 이 항목을 추가합니다.
<v-layout row justify-center>
<v-pagination v-model="pagination.page" :length="pages"></v-pagination>
<v-btn class="test">test</v-btn>
</v-layout>
자세한 것은 이쪽.
여기 행동 중인 코드펜이 있습니다.
가장 쉬운 방법은 사용하는 데이터 테이블 슬롯에 버튼을 추가하여 테이블에 상대적으로 버튼을 배치하는 것입니다.
<v-data-table
style="position: relative;">
<template slot="footer">
<v-btn style="position: absolute; left: 10px; bottom: 10px;">
test
</v-btn>
</template>
</v-data-table>
CSS에 의한 가장 간단한 방법:
데이터 테이블의 템플릿:
<template v-slot:actions-prepend>
<v-btn>
Click me !
</v-btn>
</template>
CSS:
.my-grid .v-datatable__actions > div:first-child {
flex: 1;
}
작업 코드 조각:
new Vue({
el: '#app',
methods: {
onClick() { this.dark = !this.dark; }
},
data: {
dark: true,
headers: [{
text: 'Dessert (100g serving)',
value: 'name'
},
{
text: 'Calories',
value: 'calories'
},
{
text: 'Fat (g)',
value: 'fat'
},
{
text: 'Carbs (g)',
value: 'carbs'
},
{
text: 'Protein (g)',
value: 'protein'
},
{
text: 'Iron (%)',
value: 'iron'
}
],
desserts: [{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: '1%'
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: '1%'
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: '7%'
},
{
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
iron: '8%'
}
]
}
})
.my-grid .v-datatable__actions > div:first-child {
flex: 1;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify@1.x/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@1.x/dist/vuetify.js"></script>
<div id="app">
<v-app :dark="dark">
<v-content>
<v-data-table :headers="headers" :items="desserts" class="my-grid">
<template v-slot:items="{item}">
<tr>
<td>{{item.name}}</td>
<td>{{item.calories}}</td>
<td>{{item.fat}}</td>
<td>{{item.carbs}}</td>
<td>{{item.protein}}</td>
<td>{{item.iron}}</td>
</tr>
</template>
<template v-slot:actions-prepend>
<v-btn @click="onClick">
Switch mode
</v-btn>
</template>
</v-data-table>
</v-content>
</v-app>
</div>
언급URL : https://stackoverflow.com/questions/55291648/vuetify-datatable-actions-row
반응형
'itsource' 카테고리의 다른 글
vuelidate를 사용하여 중첩된 개체를 검증할 때 오류 메시지를 vuetify로 표시 (0) | 2022.08.28 |
---|---|
폴리곤의 중심을 찾으십니까? (0) | 2022.08.28 |
vue-apollo 클라이언트에서 GraphQL 입력 유형을 정의하는 방법 (0) | 2022.08.28 |
Vue/Bluebird: 콜백이 실행되지 않음 (0) | 2022.08.28 |
ByteBuffer.allocate()와ByteBuffer.allocateDirect() (0) | 2022.08.28 |