jdtcn / BlazorDateRangePicker

A Blazor component for choosing date ranges and dates
MIT License
186 stars 34 forks source link

Data bind to single date #31

Closed davidpaulquinn closed 4 years ago

davidpaulquinn commented 4 years ago

Hi,

I'm just looking to select a single instance of the date time picker, bind it to my value and pass that to a method to call data from the api.

Thanks for any help,

Dave

DateTImePicker.txt

jdtcn commented 4 years ago

Hi.

You need to handle the selection event OnRangeSelect and call your API there, like this:

<DateRangePicker SingleDatePicker="true"
                 @bind-StartDate="StartDate" EndDate="StartDate"
                 OnRangeSelect="OnRangeSelect" />

@code {
    DateTimeOffset? StartDate { get; set; } = DateTime.Now;

    private async Task OnRangeSelect(DateRange range)
    {
        await GetRoster(range.Start);
    }
}