7 examples of 'jquery datatable disable sorting dynamically' in JavaScript

Every line of 'jquery datatable disable sorting dynamically' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
128setSorting(sorting: DataSorting): void {
129 this._sorting = sorting;
130
131 if (sorting && sorting.key) {
132 this._rows.sort((a: DataRow, b: DataRow) => {
133 let left = a.getValue(sorting.key);
134 if (left) {
135 left = (left instanceof Date) ? left.valueOf().toString() : left.toString();
136 } else {
137 left = '';
138 }
139
140 let right = b.getValue(sorting.key);
141 if (right) {
142 right = (right instanceof Date) ? right.valueOf().toString() : right.toString();
143 } else {
144 right = '';
145 }
146
147 return sorting.direction === 'asc'
148 ? left.localeCompare(right)
149 : right.localeCompare(left);
150 });
151 }
152}
70function initDataTables() {
71 addFilterOnDoneTyping();
72 // Job pairs table
73 pairTable = $('#pairTbl').dataTable({
74 "sDom": getDataTablesDom(),
75 "iDisplayStart": 0,
76 "iDisplayLength": defaultPageSize,
77 "bServerSide": true,
78 "pagingType": "full_numbers",
79
80 "sAjaxSource": starexecRoot + "services/jobs/",
81 "sServerMethod": "POST",
82 "fnServerData": fnPaginationHandler
83 });
84 setSortTable(pairTable);
85 $("#pairTbl thead").click(function() {
86 resetSortButtons();
87 });
88 // Change the filter so that it only queries the server when the user stops typing
89 $('#pairTbl').dataTable().fnFilterOnDoneTyping();
90
91}
100function toggleSort(header, col) {
101 if (column.get("direction") === "ascending") collection.trigger(event, col, "descending");
102 else collection.trigger(event, col, "ascending");
103}
90function quickSort(left, right) {
91 if (left < right) {
92 // QuickSort's effectiveness depends on its ability to partition the
93 // sequence being sorted into two subsequences of roughly equal length:
94 // by halving the length at each recursion level, the subproblems get
95 // smaller faster. To get a good partition, we must choose a pivot value
96 // that is close to the median of the values in the sequence: by
97 // definition, half of the values will fall before the median, half
98 // after it.
99 // If the sequence is already mostly sorted, then choosing the first or
100 // last value as the pivot is probably as far from the median as you
101 // could possibly get; this is a "pessimal", not optimal, choice.
102 // Choosing the middle value as the pivot is likely to be much closer to
103 // the median.
104 const pivot = (left + right) >> 1;
105 const partitionIndex = partition(pivot, left, right);
106
107 // Sort left and right
108 quickSort(left, partitionIndex - 1);
109 quickSort(partitionIndex + 1, right);
110 }
111}
1137function _setHeaderSorted($th, sorted) {
1138 // Set the supplied table header to the supplied sorted state.
1139 $th.removeClass(
1140 'gcb-sorted-none gcb-sorted-ascending gcb-sorted-descending');
1141 $th.addClass(sorted);
1142 _setIconFromSorted($th, sorted);
1143}
149_isSorting(columnIndex, sortColumn) {
150 return columnIndex === sortColumn;
151}
207function setupDataTable() {
208 var tableOptions;
209 tableOptions = {
210 "bJQueryUI" : true,
211 "sPaginationType" : "full_numbers",
212 "aaData" : [],
213 "aoColumns" : [ {
214 "sTitle" : "Parameter",
215 "sType" : "String",
216 "mData" : "name",
217 "mRender": function(data, type, full) {
218 return data;
219 }
220 }, {
221 "sTitle" : "Value",
222 "sType" : "Numeric",
223 "mData" : "value",
224 "mRender": function(data, type, full) {
225 return data;
226 }
227 }, {
228 "sTitle" : "Received Time",
229 "mData" : "receivedTime",
230 "mRender": function(data, type, full) {
231 return new Date(new Number(data));
232 },
233 "asSorting" : [ "desc" ]
234 } ],
235 "aaSorting" : [ [ 2, "desc" ] ]
236 };
237
238 table = $("#tmTable").dataTable(tableOptions);
239}

Related snippets