Datatable sorting
I am using ktui datatables but in my case sorting is not working why??
Replies (8)
Hi
Please check the examples here.
https://github.com/keenthemes/ktui/tree/main/examples/datatable
May I know if you use a local or remote data source?
Thanks
Please check the package.json and verify the KTUI version. Please try to update to the latest version.
npm install @keenthemes/ktui@latest
Thanks
Thanks for the update.
I’ve checked, and the current KTUI theme version is 1.0.25. I tried updating, but unfortunately, the sorting functionality is still not working even with this version.
Thanks for the pointers! I’ve already tried reinitializing and checked the data-sort attributes, but the sorting issue still persists. I’ll review the guides you shared and see if I missed anything.
Hi
sorting isn’t working because the <th> headers lack the required kt-table-col wrapper with kt-table-col-sort and the data-kt-datatable-column is set to a name incompatible with the data structure.
<th scope="col" data-kt-datatable-column="course_name">
<span class="kt-table-col">
<span class="kt-table-col-label">Course Name</span>
<span class="kt-table-col-sort"></span>
</span>
</th> Wrap the label and icon in <span class="kt-table-col">.
Place the label in <span class="kt-table-col-label">.
Add <span class="kt-table-col-sort"> for sorting icons.
data-kt-datatable-column must match your data keys.
If sorting isn’t needed, set data-kt-datatable-column-sort="false" on the <th>.
HEllo ,
Same I have implemented in my code but not working, if i copy paste code from here https://ktui.io/docs/datatable but also not working sorting.
here is the code
<th scope="col" class="w-30" data-kt-datatable-column="course_name">
<span class="kt-table-col">
<span class="kt-table-col-label">Course Name</span>
<span class="kt-table-col-sort">
</span>
</span>
</th>
Hi,
I have share the code here - https://gist.github.com/bhagyashri-gfi/51a83d9b10d126dea73223baeb83392f