更改数据选择器后如何重新加载数据表?

时间:2019-04-20 08:19:05

标签: c# jquery datatable

我想根据数据选择器的更改来更改数据表数据。通常不选择首次加载页面的日期选择器。从datepicker中选择一个日期后,应重新加载数据表。我该怎么办?

数据选择器。

    $('#AppointmentListDate').datepicker({
        autoclose: true,
        format: 'dd.mm.yyyy',
        language: 'tr'

    }).on('changeDate', function (ev) {
        $(this).datepicker('hide');
        });

数据表。

    $('#tblAppointmentList').dataTable({
        responsive: true,
        searching: false,
        paging: false,
        info: false,
        "ajax": {
            "url": "/Appointment/AppoinetmentList_Read",
            "dataSrc": ""
        },
    });

约会列表控制器

    [HttpGet]
    public async Task<ActionResult> AppoinetmentList_Read(string selectedDate)
    {
        DateTime today;
        if (selectedDate == null)
        {
             today = DateTime.Today;
             today = today.AddHours(7).AddMinutes(45);
        }
        else
        {
            today = DateTime.Parse(selectedDate);
            today = today.AddHours(7).AddMinutes(45);
        }


        var result = await appointmentBusiness.GetAppointmentsByDay(new GetAppointmentListByDayCommand
        {
            Date = today
        });

        return Json(result.Result);
    }

0 个答案:

没有答案
相关问题