File tree Expand file tree Collapse file tree 3 files changed +44
-6
lines changed
docs/src/pages/components Expand file tree Collapse file tree 3 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 337
337
</md-button >
338
338
</md-toolbar >
339
339
340
- <md-table md-sort =" dessert " md-sort-type =" desc " @select =" onSelect" @sort =" onSort" >
340
+ <md-table : md-sort =" sortInput.name " : md-sort-type =" sortInput.type " @select =" onSelect" @sort =" onSort" >
341
341
<md-table-header >
342
342
<md-table-row >
343
343
<md-table-head md-sort-by =" dessert" >Dessert (100g serving)</md-table-head >
374
374
<pre >{{ selectedData }}</pre >
375
375
</div >
376
376
377
+ <div class =" output" >
378
+ <h2 class =" md-title" >Sort input</h2 >
379
+ <md-input-container >
380
+ <label for =" sort-input-name" >Name</label >
381
+ <md-select name =" sort-input-name" id =" sort-input-name" v-model =" sortInput.name" >
382
+ <md-option value =" " >None</md-option >
383
+ <md-option value =" dessert" >Dessert</md-option >
384
+ <md-option value =" calories" >Calories</md-option >
385
+ <md-option value =" fat" >Fat</md-option >
386
+ </md-select >
387
+ </md-input-container >
388
+
389
+ <md-input-container >
390
+ <label for =" sort-input-type" >Type</label >
391
+ <md-select name =" sort-input-type" id =" sort-input-type" v-model =" sortInput.type" >
392
+ <md-option value =" asc" >Ascending</md-option >
393
+ <md-option value =" desc" >Descending</md-option >
394
+ </md-select >
395
+ </md-input-container >
396
+ </div >
397
+
377
398
<div class =" output" >
378
399
<h2 class =" md-title" >Current Sort</h2 >
379
400
<pre >{{ sort }}</pre >
716
737
}
717
738
],
718
739
selectedData: [],
740
+ sortInput: {
741
+ name: ' dessert' ,
742
+ type: ' asc'
743
+ },
719
744
sort: {},
720
745
page: {}
721
746
}),
Original file line number Diff line number Diff line change 48
48
},
49
49
selectedRows () {
50
50
this .numberOfSelected = Object .keys (this .selectedRows ).length ;
51
+ },
52
+ mdSort () {
53
+ this .sortBy = this .mdSort ;
54
+ this .$emit (' sortInput' );
55
+ },
56
+ mdSortType () {
57
+ this .sortType = this .mdSortType ;
58
+ this .$emit (' sortInput' );
51
59
}
52
60
},
53
61
mounted () {
Original file line number Diff line number Diff line change 64
64
this .parentTable .sortType = this .sortType ;
65
65
this .parentTable .emitSort (this .mdSortBy );
66
66
}
67
+ },
68
+ initSort () {
69
+ if (this .hasMatchSort ()) {
70
+ this .sorted = true ;
71
+ this .sortType = this .parentTable .sortType ;
72
+ }
67
73
}
68
74
},
69
75
mounted () {
70
76
this .parentTable = getClosestVueParent (this .$parent , ' md-table' );
71
-
72
- if (this .hasMatchSort ()) {
73
- this .sorted = true ;
74
- this .sortType = this .parentTable .sortType ;
75
- }
77
+ this .initSort ();
78
+ this .parentTable .$on (' sortInput' , () => {
79
+ this .initSort ();
80
+ });
76
81
}
77
82
};
78
83
</script >
You can’t perform that action at this time.
0 commit comments