1
1
<script >
2
- import DatasourceUtils from ' .. /utils/DatasourceUtils'
2
+ import DatasourceUtils from ' @ /utils/DatasourceUtils'
3
3
import Pagination from ' ./Pagination'
4
- import {EventBus } from ' ../utils/EventBus'
4
+ import {EventBus } from ' @/utils/EventBus'
5
+ import IconAsc from ' @/assets/icon-asc.png'
6
+ import IconDesc from ' @/assets/icon-desc.png'
5
7
export default {
6
8
name: ' ServerDatasource' ,
7
9
components: {Pagination},
@@ -124,7 +126,11 @@ export default {
124
126
current_page: 1 ,
125
127
selected: null , // row and Object selected on click event
126
128
indexSelected: - 1 , // index row selected on click event
127
- search: ' ' // word to search in the table,
129
+ search: ' ' , // word to search in the table,
130
+ columnSortSelected: { // Object to set a column sort data
131
+ key: null ,
132
+ order: true
133
+ }
128
134
}
129
135
},
130
136
computed: {
@@ -134,8 +140,20 @@ export default {
134
140
})
135
141
},
136
142
columnItems () {
143
+ let showArrows = (key ) => {
144
+ return (this .shouldShowUpArrow (key)) ? < img src= {IconDesc} width= " 15" / >
145
+ : < img src= {IconAsc} width= " 15" / >
146
+ }
147
+
137
148
return this .columns .map ((column , index ) => {
138
- return < th> {column .name }< / th>
149
+ if (column .order ) {
150
+ return < th on- click= {(e ) => this .sortColumn (e, column .key )}>
151
+ {column .name }
152
+ < span class = " vue-server-arrows" > {showArrows (column .key )}< / span>
153
+ < / th>
154
+ } else {
155
+ return < th> {column .name }< / th>
156
+ }
139
157
})
140
158
},
141
159
columnObjects () {
@@ -182,7 +200,10 @@ export default {
182
200
this .indexSelected = - 1
183
201
this .current_page = 1
184
202
this .$emit (' searching' , e .target .value )
185
- }
203
+ },
204
+ sortColumn: DatasourceUtils .sortColumn ,
205
+ shouldShowUpArrow: DatasourceUtils .shouldShowUpArrow ,
206
+ shouldShowDownArrow: DatasourceUtils .shouldShowDownArrow
186
207
},
187
208
watch: {
188
209
/**
@@ -208,8 +229,16 @@ export default {
208
229
position : relative ;
209
230
padding : 0 ;
210
231
}
232
+ .vue-server-arrows {
233
+ position : absolute ;
234
+ right : 0 ;
235
+ top : 6px ;
236
+ }
211
237
table {
212
238
margin-bottom : 0 ;
239
+ th {
240
+ position : relative ;
241
+ }
213
242
}
214
243
.panel-footer {
215
244
.btn-group-actions {
0 commit comments