Two instances of a DatePicker to use for Greater than and Less Than #1843

Closed
opened 2026-01-29 17:59:17 +00:00 by claunia · 2 comments
Owner

Originally created by @MG1376 on GitHub (Aug 18, 2025).

Is your feature request related to a problem? Please describe.
I have a filter template for my DatePicker, I want to use this input for a Between operator, so using one for Less Than and another for Greater Than, But when I choose a date from one picker the other one shows the same value.
You can test this (although nonsense here, your online example of FilterTemplate for this component, when you choose some titles from the multiple dropdown, if you add another instance of that multi ddl, the same values are selected )

Describe the solution you'd like
Add a counter to the FilterTemplate's context, if it solves the problem, or any other way that I could create a list or array of my Date Classes so that more than one instances of this filter can be created with different values.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context

<RadzenDataFilterProperty Property="AddedDate"
                           Title="Date" Type="typeof(DateTime?)"
                           FilterValue="Date.selectedDate"
                           TItem="Data.Entities.BillPayment">
     <FilterTemplate>
         <InputPersianDatePicker Name="Date"
                                 CssClass="form-control"
                                 @bind-Value="Date.SelectedDate"
                                 DateFormat="DateFormat.yyyy_dash_MM_dash_dd"
                                 DigitType="DigitType.English"
                                 MinDateSetOnToday="false" Style="width: 50%;"
                                 Placeholder="Begin">
         </InputPersianDatePicker>
     </FilterTemplate>
 </RadzenDataFilterProperty>    

@code {

 SelectedDateClass Date = new SelectedDateClass();

 //List<SelectedDateClass> Dates = new List<SelectedDateClass>();
// int i = 0;

 [Parameter]
 public RadzenDataFilter<BillPayment> dataFilter { get; set; }   
}

Here I set a string, Date.SelectedDate so that I get back a DateTime?, Date.selectedDate, for the filter value.

Originally created by @MG1376 on GitHub (Aug 18, 2025). **Is your feature request related to a problem? Please describe.** I have a filter template for my DatePicker, I want to use this input for a Between operator, so using one for Less Than and another for Greater Than, But when I choose a date from one picker the other one shows the same value. You can test this (although nonsense here, your online example of FilterTemplate for this component, when you choose some titles from the multiple dropdown, if you add another instance of that multi ddl, the same values are selected ) **Describe the solution you'd like** Add a counter to the FilterTemplate's context, if it solves the problem, or any other way that I could create a list or array of my Date Classes so that more than one instances of this filter can be created with different values. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** ``` <RadzenDataFilterProperty Property="AddedDate" Title="Date" Type="typeof(DateTime?)" FilterValue="Date.selectedDate" TItem="Data.Entities.BillPayment"> <FilterTemplate> <InputPersianDatePicker Name="Date" CssClass="form-control" @bind-Value="Date.SelectedDate" DateFormat="DateFormat.yyyy_dash_MM_dash_dd" DigitType="DigitType.English" MinDateSetOnToday="false" Style="width: 50%;" Placeholder="Begin"> </InputPersianDatePicker> </FilterTemplate> </RadzenDataFilterProperty> @code { SelectedDateClass Date = new SelectedDateClass(); //List<SelectedDateClass> Dates = new List<SelectedDateClass>(); // int i = 0; [Parameter] public RadzenDataFilter<BillPayment> dataFilter { get; set; } } ``` Here I set a string, Date.SelectedDate so that I get back a DateTime?, Date.selectedDate, for the filter value.
Author
Owner

@enchev commented on GitHub (Aug 19, 2025):

Selection depends on how @bind-Value is used. If you bind multiple instances to a single variable you will get described result. You need different variable for every instance.

@enchev commented on GitHub (Aug 19, 2025): Selection depends on how @bind-Value is used. If you bind multiple instances to a single variable you will get described result. You need different variable for every instance.
Author
Owner

@MG1376 commented on GitHub (Aug 19, 2025):

How? I did this, with the same result.

@if (Dates != null && Dates.Count() > 0 && counter > -1)
{
    <RadzenDataFilterProperty Property="AddedDate"
                              Title="Date" Type="typeof(DateTime?)"
                              FilterValue="Dates[counter].selectedDate"
                              TItem="Data.Entities.BillPayment">
        <FilterTemplate>
            <InputPersianDatePicker Name="Date"
                                    CssClass="form-control"
                                    @bind-Value="Dates[counter].SelectedDate"
                                    DateFormat="DateFormat.yyyy_dash_MM_dash_dd"
                                    DigitType="DigitType.English"
                                    MinDateSetOnToday="false" Style="width: 50%;"
                                    Placeholder="شروع">
            </InputPersianDatePicker>            
        </FilterTemplate>
    </RadzenDataFilterProperty>    
}


@code {

    //SelectedDateClass Date = new SelectedDateClass();

    static List<SelectedDateClass> Dates = new List<SelectedDateClass>();
    static int counter = -1;

    [Parameter]
    public RadzenDataFilter<BillPayment> dataFilter { get; set; }

    protected override void OnInitialized()
    {
        base.OnInitialized();

        Dates.Add(new SelectedDateClass());
        counter++;
    }
}

@MG1376 commented on GitHub (Aug 19, 2025): How? I did this, with the same result. ``` @if (Dates != null && Dates.Count() > 0 && counter > -1) { <RadzenDataFilterProperty Property="AddedDate" Title="Date" Type="typeof(DateTime?)" FilterValue="Dates[counter].selectedDate" TItem="Data.Entities.BillPayment"> <FilterTemplate> <InputPersianDatePicker Name="Date" CssClass="form-control" @bind-Value="Dates[counter].SelectedDate" DateFormat="DateFormat.yyyy_dash_MM_dash_dd" DigitType="DigitType.English" MinDateSetOnToday="false" Style="width: 50%;" Placeholder="شروع"> </InputPersianDatePicker> </FilterTemplate> </RadzenDataFilterProperty> } @code { //SelectedDateClass Date = new SelectedDateClass(); static List<SelectedDateClass> Dates = new List<SelectedDateClass>(); static int counter = -1; [Parameter] public RadzenDataFilter<BillPayment> dataFilter { get; set; } protected override void OnInitialized() { base.OnInitialized(); Dates.Add(new SelectedDateClass()); counter++; } } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1843