本文介绍了如何根据日期列对Json数据进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!LoadLeadCourseRecentActivityList: function () { var leadCourseId = $("#hdnLeadCourseId").val(); var args = { leadCourseId: leadCourseId } $.ajax({ url: "/Lead/LoadLeadCourseActivityList", dataType: "json", type: 'GET', data: args, cache: false, async: false, success: function (data) { var leadCourseActivities = '<table id="tblLeadCourseRecentActivities" class="table table-striped table-bordered table-hover table-responsive"><thead><tr class="primary"><th>Activity Type</th><th>Subject</th><th>Description</th><th>Due On</th></tr></thead><tbody>'; var countRA = 1; debugger; data = data.sort((function (a, b) { if (true)return (a[data.DueDate] > b[data.DueDate]) ? -1 : ((a[data.DueDate] < b[data.DueDate]) ? 0 : 1); //else return (b[data.DueDate] > a[data.DueDate]) ? -1 : ((b[data.DueDate] < a[data.DueDate]) ? 1 : -1); })); //data = sortByKey(data, 'data.DueDate'); //data = sortfun(data, 'data.DueDate'); $.each(data, function (i, CourseActivity) { if (CourseActivity.ActivityTypeCode == null) CourseActivity.ActivityTypeCode = ""; if (CourseActivity.Subject == null) CourseActivity.Subject = ""; if (CourseActivity.Description == null) CourseActivity.Description = ""; if (CourseActivity.DueDate == null) CourseActivity.DueDate = ""; if (countRA <= 5) { leadCourseActivities += "<tr><td>" + CourseActivity.ActivityTypeCode + "</td><td>" + CourseActivity.Subject + "</td><td>" + StringConcate(CourseActivity.Description) + "</td><td>" + $.format.date(CourseActivity.DueDate, "dd-MMM-yyyy hh:mm a") + "</td></tr>"; } countRA++; }); leadCourseActivities += "</tbody></table>"; $('#dvRecentActivity').html(leadCourseActivities); }, error: function () { alert('Error while loading lead course activities'); } }); }推荐答案 这篇关于如何根据日期列对Json数据进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-30 02:46