简体   繁体   English

如何根据日期值对 html 表列值进行排序

[英]How to sort an html table column values based on Date values

I am working with some stored database (EF) values and displaying them in an html table for generating a report (via API request).我正在使用一些存储的数据库 (EF) 值并将它们显示在 html 表中以生成报告(通过 API 请求)。 This is how i am calling the variables这就是我调用变量的方式

    foreach (var obj in meeting.Where(n => n.ParentID == vmContent.ParentID))
                {
                    Compliance = Compliance + obj.Compliance;
                    DirectivesList = DirectivesList + obj.MeetingTypeName + obj.MeetingDate.ToDatePickerFormat() + obj.Directives;
                }

And this is how i am writing the code for HTML tables这就是我为 HTML 表编写代码的方式

            <td style='font-family:&quot;Bookman Old Style&quot;,serif;vertical-align: top;border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; padding:5px;width:170px'>
            <p><span style='font-size:11pt'>" + DirectivesList + @"</span></p>
            </td>
            <td style='font-family:&quot;Bookman Old Style&quot;,serif;vertical-align: top;border-bottom:1px solid black; border-left:none; border-right:1px solid black; border-top:none; padding:5px;width:170px'>
            <p>" + Compliance + @"</p>
            </td>

This is the way my table columns are appearing Table Preview这是我的表格列的显示方式表格预览

For me, all else is working fine only problem being, I want to sort these values based on the meeting date which is included inside the Directives' List.对我来说,其他一切都很好,唯一的问题是,我想根据指令列表中包含的会议日期对这些值进行排序。 Any ideas how to do that without using queries?任何想法如何在不使用查询的情况下做到这一点? Can I sort these values based on Meeting Date using HTML/CSS/Javascript, without using any button?我可以使用 HTML/CSS/Javascript 根据会议日期对这些值进行排序,而不使用任何按钮吗?

You can order your meetings in your code behind.您可以在后面的代码中安排您的会议。

var meetings = meeting.Where(n => n.ParentID == vmContent.ParentID).OrderByDescending(x => x.MeetingDate);
foreach (var obj in meetings)
{

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM