简体   繁体   中英

Open telerik blazor DateRangePicker on calendar icon click

I need to open telerik blazor date range picker on calendor Icon click.
I was tried to find the solution but can not able to find proper that is work for me.
The telerik document have no such event to take care of it on different control click or may be I missed that. Can someone please help me with the same.

I tried to recall the DateRangePickerOpenEeventtArgs but not able to achieve it.

Thanks in advance!!

在此处输入图像描述

I found my answer in telerik document itself.
We need to create a refType of TelerikDateRangePicker like below:

<TelerikButton OnClick="@OpenPicker">Open DateRangePicker</TelerikButton>

<TelerikDateRangePicker @ref="@DateRangePickerRef"
                        @bind-StartValue="@DateRangePickerStartValue"
                        @bind-EndValue="@DateRangePickerEndValue" />

@code {
    // the component type depends on the value type, could be also DateTime?
    private TelerikDateRangePicker<DateTime> DateRangePickerRef { get; set; }

    private DateTime DateRangePickerStartValue { get; set; } = DateTime.Now;

    private DateTime DateRangePickerEndValue { get; set; } = DateTime.Now.AddDays(10);

    
    void OpenPicker()
    {
        DateRangePickerRef.Open();
    }
}

So that reference directly hit our control from methods.

ref link: telerik blazor date range event handling

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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