Twitter bootstrap 3 在DateTimePicker中用图标或颜色突出显示一天。(MVC和引导)

Twitter bootstrap 3 在DateTimePicker中用图标或颜色突出显示一天。(MVC和引导),twitter-bootstrap-3,asp.net-mvc-5,Twitter Bootstrap 3,Asp.net Mvc 5,我有一张类似下图的表格 我希望Date列中的值在 日期时间选择器(或特定颜色) 可能吗?最好的方法是什么?有什么例子吗 多谢各位 请注意,我使用MVC和Bootstrap 3在控制器中复制它 public ActionResult GetArrayofDates() { DateTime[] d = new DateTime[] { new DateTime(201

我有一张类似下图的表格

我希望Date列中的值在 日期时间选择器(或特定颜色)

可能吗?最好的方法是什么?有什么例子吗

多谢各位


请注意,我使用MVC和Bootstrap 3在控制器中复制它

public ActionResult GetArrayofDates()
            {
                DateTime[] d = new DateTime[]
                {
                    new DateTime(2019,9,27),
                    new DateTime(2019,9,25),
                    new DateTime(2015,7,27),
                    new DateTime(2019,5,5)
                };

                return View(d);
            }

这就是视图

@{
    ViewBag.Title = "GetArrayofDates";
}
<link href="~/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
<style>
    .highlight {
        background-color: #ff0000 !important;
        color: #ffffff !important;

    }
    .nothighlight{
        background-color:#fff7f7;
        color:#000000;
    }
</style>
<h2>GetArrayofDates</h2>
@{

    for (int i = 0; i < Model.Length; i++)
    {
        <h3>@Model[i]</h3>
    }
}
<div id="calandar">

</div>
<script src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="~/Scripts/jquery-ui-1.12.1.js"></script>
<script>



    var dates = []

@foreach (var item in Model)
{ 

    //@: allow you to write javascritp/hhtml code inside c# code which you specific using @ which allow write c# inside javascrpit/html
    @:dates.push('@item.ToString("yyyy-M-dd")');
}
    console.log(dates);
    console.log(dates["0"])

    $("#calandar").datepicker({
        todayHighlight: true,
        changeYear: true,
        changeMonth: true,
        minDate: new Date(2010,1,1),
        beforeShowDay: function (date) {

            var calender_date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ('0' + date.getDate()).slice(-2);
            console.log(calender_date)
            var search_index = $.inArray(calender_date, dates);

            if (search_index > -1) {
                return [true,'highlight','Employee Worked on this day.' ];
            } else {
                return [true, 'nothighlight', 'Employee did not Work on this day.'];
            }

        }
    });        








</script>
@{
ViewBag.Title=“GetArrayofDates”;
}
.亮点{
背景色:#ff0000!重要;
颜色:#ffffff!重要;
}
.不亮{
背景色:#fff7f7;
颜色:#000000;
}
GetArrayofDates
@{
对于(int i=0;i-1){
return[true、'highlight'、'Employee Worked on this day';
}否则{
return[true,'nothighlight','Employee当天没有工作';
}
}
});        
这个完整的工作示例确保匹配从服务器发送的日期格式,并像我一样放入数组,一切都会正常。
下载jqueryui,使用UI-CSS,我想你应该知道,在showDay之前使用
听起来是可能的。您可以将控制器操作中的日期作为日期数组传递,并使用
inArray
检查并突出显示这些日期。你能显示当前的日期选择器和控制器方法代码吗?目前还没有代码,我想知道是否可能以及如何解决。谢谢你的重播。。也许能帮助你开始。你可以随时编辑文章,提供你已经尝试完成的日期突出显示。太好了!!非常感谢你。