Setting Initial Ordering as Descending
Setting Initial Ordering as Descending
RaZzLe
Posts: 4Questions: 2Answers: 0
vue version: 3.2.13
datatables.net-dt: 2.1.8
datatables.net-vue3: 3.0.2
I want to order my table by its first column (which is ID) on load. I have tried columns.orderSequence
as described here but it doesn't help.
Here is my data table:
<DataTable
class="display"
width="100%"
:columns="keywordColumns"
:data="keywords"
:options="datatableOpts"
:key="keywordTableId"
ref="keywordDatatable"
>
<thead>
<tr>
<th>ID</th>
<th>Anahtar Kelime</th>
<th>Oluşturma Tarihi</th>
<th>Güncelleme Tarihi</th>
</tr>
</thead>
<template #column-4="props">
<button-base
button-text="Etiketler"
button-type="button"
button-class="primary"
xxlarge="xxlarge"
@click="openTagModal(props.rowData)"
></button-base>
</template>
<template #column-5="props">
<button-base
button-text="Düzenle"
button-type="button"
button-class="primary"
xxlarge="xxlarge"
@click="openInsertModal(props.rowData)"
></button-base>
</template>
<template #column-6>
<button-base
button-text="Sil"
button-type="button"
button-class="primary"
xxlarge="xxlarge"
></button-base>
</template>
</DataTable>
And, my column definitions are as below:
data() {
return {
//other stuff..
keywordColumns: [
{ data: "id", orderSequence: ["desc"] },
{ data: "text" },
{ data: "createtime" },
{ data: "updatetime" },
{ sortable: false, width: '84px' },
{ sortable: false, width: '84px' },
{ sortable: false, width: '60px' }
],
keywords: [],
}
}
Does anyone know how to properly define column ordering rule on table load on Vue?
Thank you in advance.
This question has an accepted answers - jump to answer
Answers
Use the
order
parameter to set the default order for the table.Allan