Hi
I have below code . I want to set Session Date as default sort
Code
Segment
Session Date
Session Start Time
Session End Time
Mentor
Student
Session Status
ActionThanks
Hi
I have below code . I want to set Session Date as default sort
Segment
Session Date
Session Start Time
Session End Time
Mentor
Student
Session Status
ActionThanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Apr 2, 2023, 2:11 PM EDT
in your sql code you can order by sessionDate or if it is a Jquery DataTable then
$(document).ready(function () { $('#tbldata').DataTable({ order: [[2, 'desc']], }); });Tuhin PaulRank #7 · 71.9K reputationPosted Apr 2, 2023, 5:35 PM EDT
Use the
data-orderattribute of thethelement to specify the default sort order for a column. You can set it to the index of the column that you want to sort by, starting from 0.Tuhin PaulRank #7 · 71.9K reputationPosted Apr 2, 2023, 5:36 PM EDT
you can add the data-order attribute to the "Session Date" th element
This will make the "Session Date" column the default sort column and will sort the table based on the values in that column when the table is initialized.
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 2, 2023, 9:06 PM EDT
Hi Tuhin
Below is the code . Where is should change
Below is the code behind
htmlTable.Append("" + Utility.GetOrdinalNo(Convert.ToInt32(colum.Segment)) + ""); htmlTable.Append("" + Convert.ToDateTime(colum.SessionDate).ToString("dd-MM-yyyy") + ""); htmlTable.Append("" + Convert.ToDateTime(colum.SessionStartTime).ToString("HH:mm") + "");Ramco RamcoRank #462 · 5.4K reputationPosted Apr 2, 2023, 9:09 PM EDT
Hi Sachin
When i use that i get error - DataTables warning: table id=tbldata - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 3, 2023, 2:20 AM EDT
Hi Tuhin
I have written like below but still not working
Thanks
Anandu G NathRank #681 · 3.5K reputationPosted Dec 27, 2023, 3:45 AM EST
$(document).ready(function () { $('#tbldata').DataTable({ "order": [[1, "asc"]] // "1" refers to the index of the "Session Date" column (zero-based index) }); });Add the necessary scripts for DataTables in your HTML or ASPX file