<div class="form-group row">
<div class="col">
<label>WorkSpace:</label>
<SfDropDownList TItem="GenericKeyValuePair" TValue="string" PopupHeight="230px"
DataSource="@WorkSpacesList" @bind-Value="@SelectedWorkSpace">
<DropDownListEvents TValue="string" ValueChange="@OnChangeWorkSpace"></DropDownListEvents>
<DropDownListFieldSettings Text="Name" Value="Id"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Profile</label>
<SfDropDownList TItem="GenericKeyValuePair" TValue="string" PopupHeight="230px"
DataSource="@ProfileList" @bind-Value="@SelectedProfile" Index="0">
<DropDownListFieldSettings Text="Name" Value="Id"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Role:</label>
<SfDropDownList TItem="GenericKeyValuePair" TValue="string" PopupHeight="230px"
DataSource="@RoleList" @bind-Value="@SelectedRole" Index="0">
<DropDownListFieldSettings Text="Name" Value="Id"></DropDownListFieldSettings>
</SfDropDownList>
</div>
</div>
<div class="form-group row">
<div class="col">
<label>WorkSpace:</label>
<SfDropDownList TItem="GameFields" TValue="int?" PopupHeight="230px"
DataSource="@Games" @bind-Value="@DropVal">
<DropDownListEvents TValue="int?" ValueChange="@OnChangeWorkSpace"></DropDownListEvents>
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Profile</label>
<SfDropDownList TItem="MultiGameFields" TValue="string" PopupHeight="230px"
DataSource="@MultiGames" @bind-Value="@SecondVal">
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Role:</label>
<SfDropDownList TItem="ThirdGameFields" TValue="string" PopupHeight="230px"
DataSource="@ThirdGames" @bind-Value="@ThirdVal">
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
</div>
@code
{
SfDropDownList<int?, GameFields> DDLObject;
public int? DropVal { get; set; } = 2;
public string SecondVal { get; set; }
public string ThirdVal { get; set; }
public class GameFields
{
public int ID { get; set; }
public string Text { get; set; }
}
private ObservableCollection<GameFields> Games = new ObservableCollection<GameFields>() {
new GameFields(){ ID= 1, Text= "American Football" },
new GameFields(){ ID= 2, Text= "Badminton" },
new GameFields(){ ID= 3, Text= "Basketball" },
new GameFields(){ ID= 4, Text= "Cricket" },
new GameFields(){ ID= 5, Text= "Football" },
new GameFields(){ ID= 6, Text= "Golf" },
new GameFields(){ ID= 7, Text= "Hockey" }
};
public class MultiGameFields
{
public string ID { get; set; }
public string Text { get; set; }
}
private List<MultiGameFields> MultiGames;
public class ThirdGameFields
{
public string ID { get; set; }
public string Text { get; set; }
}
private List<ThirdGameFields> ThirdGames;
public void OnChangeWorkSpace(Syncfusion.Blazor.DropDowns.ChangeEventArgs<int?> args)
{
if (args.Value > 4)
{
this.MultiGames = new List<MultiGameFields>()
{
new MultiGameFields(){ ID= "Game1", Text= "American Football" },
new MultiGameFields(){ ID= "Game2", Text= "Badminton" },
new MultiGameFields(){ ID= "Game3", Text= "Basketball" },
new MultiGameFields(){ ID= "Game4", Text= "Cricket" },
new MultiGameFields(){ ID= "Game5", Text= "Football" }
};
} else
{
this.ThirdGames = new List<ThirdGameFields>()
{
new ThirdGameFields(){ ID= "Game11", Text= "American Football" },
new ThirdGameFields(){ ID= "Game21", Text= "Badminton" },
new ThirdGameFields(){ ID= "Game31", Text= "Basketball" },
new ThirdGameFields(){ ID= "Game41", Text= "Cricket" },
new ThirdGameFields(){ ID= "Game51", Text= "Football" }
};
}
}
} |
<div class="form-group row">
<div class="col">
<label>WorkSpace:</label>
<SfDropDownList TItem="GenericKeyValuePair" TValue="int?" PopupHeight="230px"
DataSource="@FirstDdl" @bind-Value="@DropVal">
<DropDownListEvents TValue="int?" ValueChange="@OnChangeWorkSpace"></DropDownListEvents>
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Profile</label>
<SfDropDownList TItem="GameFields" TValue="int?" PopupHeight="230px"
DataSource="@SecondDdl" @bind-Value="@SecondVal">
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
<div class="col">
<label>Role:</label>
<SfDropDownList TItem="GameFields" TValue="int?" PopupHeight="230px"
DataSource="@ThridDdl" @bind-Value="@ThirdVal">
<DropDownListFieldSettings Text="Text" Value="ID"></DropDownListFieldSettings>
</SfDropDownList>
</div>
</div>
@code
{
public ObservableCollection<GameFields> SecondDdl { get; set; } = new ObservableCollection<GameFields>();
public ObservableCollection<GameFields> ThridDdl { get; set; } = new ObservableCollection<GameFields>();
public class GameFields
{
public int ID { get; set; }
public string Text { get; set; }
}
public void OnChangeWorkSpace(ChangeEventArgs<int?> args)
{
SecondDdl = new ObservableCollection<GameFields>();
ThridDdl = new ObservableCollection<GameFields>();
var item = ComplexGames.First(c => c.ID == DropVal.Value);
SecondDdl = item.Games;
ThridDdl = item.Games;
//foreach (var game in item.Games)
//{
// SecondDdl.Add(new GenericKeyValuePair
// {
// ID = game.ID,
// Text = game.Text
// });
// ThridDdl.Add(new GenericKeyValuePair
// {
// ID = game.ID,
// Text = game.Text
// });
//}
}
}
|
|