Skip to content

Commit da94fe5

Browse files
justice47Yousef Sultan
authored andcommitted
Added initial column sort prop initSortCol (#42)
1 parent 2126ec3 commit da94fe5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ first value of perPage
184184
</pre>
185185
</td>
186186
</tr>
187+
<tr>
188+
<td>
189+
<code>initSortCol</code>
190+
</td>
191+
<td>
192+
Default column for sorting on component initialization
193+
</td>
194+
<td>
195+
<pre>
196+
-1 (default) // By default table is not sorted by any column
197+
</pre>
198+
</td>
199+
</tr>
187200
<tr>
188201
<td>
189202
<code>onClick</code>
@@ -307,7 +320,7 @@ true (default) // Whether exportable
307320
<code>printable</code>
308321
</td>
309322
<td>
310-
Add printing functionality
323+
Add printing functionality
311324
</td>
312325
<td>
313326
<pre>

src/DataTable.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@
138138
paginate: {default: true},
139139
exportable: {default: true},
140140
printable: {default: true},
141-
locale: {default: 'en'}
141+
locale: {default: 'en'},
142+
initSortCol: {default: -1}
142143
},
143144
144145
data: () => ({
@@ -365,6 +366,7 @@
365366
if (!(this.locale in locales))
366367
console.error(`vue-materialize-datable: Invalid locale '${this.locale}'`);
367368
this.currentPerPage = this.currentPerPage
369+
this.sortColumn = this.initSortCol
368370
}
369371
}
370372
</script>
@@ -620,4 +622,4 @@
620622
.rtl {
621623
direction: rtl;
622624
}
623-
</style>
625+
</style>

0 commit comments

Comments
 (0)