0
내 머리를이 벽으로 부딪 치고 있습니다. 질문 제목에서 알 수 있듯이 MVC Razor View에는 JQuery Datatable이 있습니다. 하나의 열에는 영국식 날짜 (dd/mm/yyyy)가 표시되며 영국식 날짜를 기준으로이 열을 정렬하고 싶습니다.JQuery DataTable UK 날짜 정렬 작동하지 않음
나는 내 면도기보기
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"date-uk-pre": function (a) {
var ukDatea = a.split('/');
return (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
},
"date-uk-asc": function (a, b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"date-uk-desc": function (a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
$('#example').dataTable({
stateSave: true,
"aoColumnDefs" : [
{"aTargets" : [1] , "sType" : "uk_date"}
]
});
});
</script>
<table cellpadding="0" cellspacing="0" border="1" class="cdates" id="example">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Status</th>
<th>Applicants</th>
</tr>
</thead>
<tbody>
@foreach (var cd in Model)
{
<tr>
<td><strong>@cd.CourseName</strong></td>
<td>@cd.CourseDate</td>
<td>@cd.CourseStatus</td>
<td>@Html.ActionLink("View Applicants", "CDApps", "Portfolio", new { @id = @cd.CourseDateID, @[email protected] }, null)</td>
</tr>
}
</tbody>
</table>
하지만 여전히 내 날짜 정렬이 작동하지 않는 내에서 다음 있습니다. 스택 오버플로에 대한 다른 비슷한 질문을 살펴 봤지만 여전히 작동하지 않습니다.
누구나 올바른 방향으로 나를 가리킬 수 있습니까?
도움 주셔서 감사합니다.
감사하지만 작동하지 않았습니다. 그것은 당신의 대답으로 모든 컬럼에서 실제로 정렬을 제거했습니다. – tgriffiths
다른 답변을 시도했는데 정렬이 다시 돌아 왔지만 날짜 열은 여전히 올바르게 정렬되지 않았습니다. 다른 제안? – tgriffiths
내 업데이트 된 답변보기 –