Hi,
I need to have a DateRangePicker to allow a user to select a date range in the Toolbar. Ideally, I want to implement this in a DropDownList with the Placeholder text of "All Dates". When the drop down list is clicked, the DateRangePicker is shown and a user can select a range of dates which will then show after focus is lost. The user should be able to select "All Dates" again so no "date range" is selected to send to my API. See attached screen show. Any help is much appreciated!
Jimmy
<ToolBarTemplateItem>
<TelerikDropDownList Data="@dateLookupModel" TextField="LookupTextField" ValueField="LookupValueField" @bind-Value="@dateLookupType" width="125px"></TelerikDropDownList>
</ToolBarTemplateItem>
<ToolBarSeparator />
<ToolBarTemplateItem>
Dates: <TelerikDateRangePicker Class="daterangepicker-no-labels" @bind-StartValue="@StartValue"
@bind-EndValue="@EndValue"></TelerikDateRangePicker>
</ToolBarTemplateItem>
<ToolBarSeparator />
Code:
public DateTime? StartValue { get; set; } = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
public DateTime? EndValue { get; set; } = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
private FilterDate dateLookupType { get; set; } = FilterDate.AllDates;
private List<LookupItemModel<FilterDate>> dateLookupModel { get; set; } =
new();
{
dateLookupModel.Add(new LookupItemModel<FilterDate>()
{
LookupTextField = ((FilterDate)value).GetAttribute<DisplayText>().Text,
LookupValueField = (int)value,
LookupSortValue = ((FilterDate)value).GetAttribute<OrderAttribute>().Order
});
dateLookupModel.Sort((x, y) => x.LookupSortValue.CompareTo(y.LookupSortValue));
}