如何根据 Web 服务的响应禁用日期选择器中的星期几

How to disable days of week in date picker based on response from web service

在我的项目中有很多员工,他们每个人每周都有自己的时间表,我实现了一个 Web 服务,其中 returns 一个整数列表,表示指定员工的工作日,所有这一切的主要思想是我需要防止用户在一周的其他日子进行约会.. 如何从日期选择器中隐藏那些日子?或者是否有其他方法可以做到这一点?

网络服务

[WebMethod]

    public void getWorkDays(int id)
    {
        WorkDays wd = new WorkDays(id);

        List<Days> workDays = new List<Days>();
        String docSch_query = "select * from workDays where empId = " + id + " and status=1";
        DBConnect conn = new DBConnect();
        DataTable dt = conn.select(docSch_query);

        foreach (DataRow r in dt.Rows)
        {
            switch (r["dayId"].ToString())
            {
                case "1":
                    workDays.Add(new Days(1,"sat"));
                    break;
                case "2":
                    workDays.Add(new Days(2, "sun"));
                    break;
                case "3":
                    workDays.Add(new Days(3, "mon"));
                    break;
                case "4":
                    workDays.Add(new Days(4, "tus"));
                    break;
                case "5":
                    workDays.Add(new Days(5, "wed"));
                    break;
                case "6":
                    workDays.Add(new Days(6, "thu"));
                    break;
            } 
        }

        JavaScriptSerializer js = new JavaScriptSerializer();
        Context.Response.Write(js.Serialize(workDays));           
    }

日期选择器

$(document).ready(function () {

        var dates=$.ajax({
            type: "POST",
            url: "getdays.asmx/getWorkDays",
            data: {id:<%#int.Parse(Session["appWith"].ToString())%>},
            dataType: "json",

            success: function (data) {

                return data.d;
            }
        });

        $('#edob').datepicker({

            firstDay: 3,
            beforeShowDay: function (date) {
                var available = $.inArray(date.getDay(), dates['int']) > -1;

                if (available) {
                    return [1];   //return available date
                }
                else {
                    return [0];   //return not available
                }
            }
        });
    })

我找到了我的问题的解决方案..

$(document).ready(function () {
        var dates = $.parseJSON(
            $.ajax({
                type: "POST",
                url: "getdays.asmx/getWorkDays",
                data: { id: <%=int.Parse(Session["appWith"].ToString())%> },
                dataType: "json",
                async: false
            }).responseText);

        $('#edob').datepicker({

            firstDay: 3,
            beforeShowDay: function (date) {
                var a =[];
                var weekend = false;
                for (i = 0; i < dates.length; i++) {
                    a.push(dates[i].Id);
                }
                var weekend = date.getDay() == 5 || date.getDay() == 6 || !($.inArray(date.getDay(),a)>-1);
                return [!weekend, weekend ? 'myweekend' : ''];
            }
      });
    });