@using Syncfusion.EJ2.Blazor.Navigations
@using Syncfusion.EJ2.Blazor.Grids
<EjsTab>
<TabItems>
<TabItem>
<ChildContent>
<TabHeader Text="Grid"></TabHeader>
</ChildContent>
<ContentTemplate>
<EjsGrid TValue="GridFields" DataSource="@GridData" EnableRtl="true" AllowTextWrap="true">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(GridFields.TrainNo) HeaderText="Train No" IsPrimaryKey="true" Width="120" Type="@ColumnType.Number"></GridColumn>
<GridColumn HeaderText="حذف" Width="20">
<GridCommandColumns>
<GridCommandColumn Type="CommandButtonType.Edit" ButtonOption="@(new CommandButtonOptions() {IconCss="e-icons e-edit", CssClass="e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Delete" ButtonOption="@(new CommandButtonOptions() {IconCss="e-icons e-delete", CssClass="e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Save" ButtonOption="@(new CommandButtonOptions() {IconCss="e-icons e-save", CssClass="e-flat" })"></GridCommandColumn>
<GridCommandColumn Type="CommandButtonType.Cancel" ButtonOption="@(new CommandButtonOptions() {IconCss="e-icons e-cancel", CssClass="e-flat" })"></GridCommandColumn>
</GridCommandColumns>
</GridColumn>
</GridColumns>
</EjsGrid>
</ContentTemplate>
</TabItem>
</TabItems>
</EjsTab>
@code{
public List<GridFields> GridData { get; set; }
protected override void OnInitialized()
{
GridData = Enumerable.Range(1, 5).Select(x => new GridFields()
{
TrainNo = 1000 + x,
Name = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)]
}).ToList();
}
public class GridFields
{
public int? TrainNo { get; set; }
public string Name { get; set; }
}
}
|