Hi,
I'm quite new with telerik and I'm facing a probleme.
A use the grid to follow the status of a property. These status is defined by an enum (it could have been a dictonary, anyway)
When I bind my Grid datasource, in there is an int field representing the enum status.
IE: 0=open, 1=Closed,...
So I've bound the enum to the comboox, TextField and ValueField displays the correct data but on load for example, i'm not able to use the @bind-Value to the correct row. even more, on runtime, if I change one combobox, every comboboxes changes their value
I don't see the solution
<TelerikGrid Data="@WorkingData"
Height="auto"
Pageable="true"
Sortable="true"
PageSize=30
Resizable="true"
EditMode="GridEditMode.Popup">
<GridColumns>
<GridColumn Field="@(nameof(Work.Status))" Title="Status" Editable=true >
<Template>
<TelerikComboBox Width="100%" Data="@comboData" TextField="Value" ValueField="Key" @bind-Value="@cbValue" ></TelerikComboBox>
</Template>
</GridColumn>
<GridColumn Field="@(nameof(Work.Comment))" Title="Comment" />
</GridColumns>
</TelerikGrid>
@code
{
enum TicketStatus
{
Open = 0,
Close = 1,
Planned = 2,
Canceled = 3
}
public class Work
{
public int Status { get; set; }
public string Comment { get; set; }
}
private List<Work> WorkingData;
private Dictionary<int, string> comboData;
private int cbValue;
protected override void OnInitialized()
{
base.OnInitialized();
comboData = Enum.GetValues(typeof(TicketStatus)).Cast<Enum>().ToDictionary(t => (int)(object)t, t => t.ToString());
WorkingData = new List<Work>
{
new Work{Status=1,Comment="My First property"},
new Work{Status=3,Comment="My second property"},
new Work{Status=2,Comment="My Third property"},
};
cbValue = 0;
}
}
Does anyonce could help me
Regards;