@foreach (var block in blocks.OrderBy(e => e.Order))
{
<div>@block.Name</div>
<EjsDropDownButton Content="Block Items">
<DropDownButtonEvents ItemSelected="@(e => SelectMenuItem(block, e.Item.Text))"></DropDownButtonEvents>
<DropDownButtonItems>
<DropDownButtonItem Text="Display Logic"></DropDownButtonItem>
<DropDownButtonItem Text="Add Block Above"></DropDownButtonItem>
<DropDownButtonItem Text="Add Block Below"></DropDownButtonItem>
<DropDownButtonItem Text="Delete"></DropDownButtonItem>
</DropDownButtonItems>
</EjsDropDownButton>
}
@code {
List<Block> blocks = new List<Block>();
protected override void OnInitialized()
{
Block blockB = new Block() { Name = "Block 2", Order = 2 };
blocks.Add(blockB);
Block blockA = new Block() { Name = "Block 1", Order = 1 };
blocks.Add(blockA);
}
public void SelectMenuItem(Block block, string text)
{
Block selectedBlock = block;
string selectedtext = text;
}
public class Block
{
public int Order { get; set; }
public string Name { get; set; }
}
}
|
@foreach (var block in blocks.OrderBy(e => e.Order))
{
<div>@block.Name</div>
<EjsDropDownButton @key="block" Content="Block Items">
<DropDownButtonEvents ItemSelected="@(e => SelectMenuItem(block, e.Item.Text))"></DropDownButtonEvents>
<DropDownButtonItems>
<DropDownButtonItem Text="Display Logic"></DropDownButtonItem>
<DropDownButtonItem Text="Add Block Above"></DropDownButtonItem>
<DropDownButtonItem Text="Add Block Below"></DropDownButtonItem>
<DropDownButtonItem Text="Delete"></DropDownButtonItem>
</DropDownButtonItems>
</EjsDropDownButton>
}
<Syncfusion.EJ2.Blazor.Buttons.EjsButton OnClick="SwitchBlocks" Content="Switch Block Orders"></Syncfusion.EJ2.Blazor.Buttons.EjsButton>
@code{
List<Block> blocks = new List<Block>();
protected override void OnInitialized()
{
Block blockB = new Block() { Name = "Block 2", Order = 2 };
blocks.Add(blockB);
Block blockA = new Block() { Name = "Block 1", Order = 1 };
blocks.Add(blockA);
}
public void SelectMenuItem(Block block, string text)
{
Block selectedBlock = block;
string selectedtext = text;
}
public void SwitchBlocks()
{
foreach (var block in blocks)
{
if (block.Order == 1)
block.Order = 2;
else if (block.Order == 2)
block.Order = 1;
}
}
public class Block
{
public int Order { get; set; }
public string Name { get; set; }
}
}
|