Seems like DropDownDataGrid still does not select item on initial value set using @bind-Value #417

Closed
opened 2026-01-29 17:36:58 +00:00 by claunia · 1 comment
Owner

Originally created by @OndrejUzovic on GitHub (May 19, 2022).

In version 3.18.10, if @bind-Value is used in DropDownDataGrid the value is not displayed.

image

@page "/"

@using Radzen;
@using Radzen.Blazor;
@using System.Linq.Dynamic.Core
@using System.Collections

<div style="width:700px; height:500px; background-color:beige;">

    <RadzenDropDownDataGrid TValue="string" @bind-Value=myCurrentValue LoadData="@OnLoadData" AllowClear="true"
                            Data=@myCustomCustomersData Count="@myCount"
                            TextProperty="CompanyName" ValueProperty="CustomerID" />

</div>

@code {
    public class Customer
    {
        public string CustomerID { get; set; }
        public string CompanyName { get; set; }
    }

    IEnumerable myCustomersDb;
    
    int myCount;
    IEnumerable myCustomCustomersData;
    string myCurrentValue;


    protected override void OnInitialized()
    {
        var tmpCustomers = new List<Customer>();
        for (int i = 0; i < 100; ++i)
        {
            tmpCustomers.Add(new Customer() { CustomerID = i.ToString(), CompanyName = $"Name {i}" });
        }

        myCurrentValue = "80";
        myCustomersDb = tmpCustomers;
    }


    void OnLoadData(LoadDataArgs args)
    {
        var query = myCustomersDb.AsQueryable();

        myCount = query.Count();

        if (args.Skip != null)
        {
            query = query.Skip(args.Skip.Value);
        }

        if (args.Top != null)
        {
            query = query.Take(args.Top.Value);
        }

        myCustomCustomersData = query;

        InvokeAsync(StateHasChanged);
    }
}

Or is this intended behavior?

Originally created by @OndrejUzovic on GitHub (May 19, 2022). In version 3.18.10, if @bind-Value is used in DropDownDataGrid the value is not displayed. ![image](https://user-images.githubusercontent.com/55758368/169276469-81261822-93d1-44a2-ab3f-7601b5bdb303.png) ``` @page "/" @using Radzen; @using Radzen.Blazor; @using System.Linq.Dynamic.Core @using System.Collections <div style="width:700px; height:500px; background-color:beige;"> <RadzenDropDownDataGrid TValue="string" @bind-Value=myCurrentValue LoadData="@OnLoadData" AllowClear="true" Data=@myCustomCustomersData Count="@myCount" TextProperty="CompanyName" ValueProperty="CustomerID" /> </div> @code { public class Customer { public string CustomerID { get; set; } public string CompanyName { get; set; } } IEnumerable myCustomersDb; int myCount; IEnumerable myCustomCustomersData; string myCurrentValue; protected override void OnInitialized() { var tmpCustomers = new List<Customer>(); for (int i = 0; i < 100; ++i) { tmpCustomers.Add(new Customer() { CustomerID = i.ToString(), CompanyName = $"Name {i}" }); } myCurrentValue = "80"; myCustomersDb = tmpCustomers; } void OnLoadData(LoadDataArgs args) { var query = myCustomersDb.AsQueryable(); myCount = query.Count(); if (args.Skip != null) { query = query.Skip(args.Skip.Value); } if (args.Top != null) { query = query.Take(args.Top.Value); } myCustomCustomersData = query; InvokeAsync(StateHasChanged); } } ``` Or is this intended behavior?
Author
Owner

@enchev commented on GitHub (May 20, 2022):

Hi @OndrejUzovic,

Since the item is not part of the current page (the main purpose of this component is to page lookup data unlike DropDown where all data are available at once) you can help by setting SelectedItem property like this:
image
image

@enchev commented on GitHub (May 20, 2022): Hi @OndrejUzovic, Since the item is not part of the current page (the main purpose of this component is to page lookup data unlike DropDown where all data are available at once) you can help by setting SelectedItem property like this: ![image](https://user-images.githubusercontent.com/5804953/169478329-ab647db4-16b4-4b57-b682-16ce135c355a.png) ![image](https://user-images.githubusercontent.com/5804953/169478345-70f9f80f-f851-45f4-8e1c-80d14cad2442.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#417