@page "/EmpGrid"
@using RepairSpaceApp.Data;
@using RepairSpaceApp.DataAccessLayer;
@using RepairSpaceApp.Services;
@inject RepairSpaceApp.Services.EmployeeService EmpService
@using Syncfusion.Blazor.Grids
@using System.Text.Json
<h3>Emp Grid</h3>
<div id="ControlRegion">
<SfGrid ID="Grid" DataSource="@empList" @ref="Grid" AllowPaging="true" AllowFiltering="true" AllowReordering="true" AllowResizing="true" AllowGrouping="true" AllowExcelExport="true" AllowSelection="true"
AllowSorting="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update","ExcelExport","Search"})" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.FilterBar"></GridFilterSettings>
<GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>
<GridEvents OnToolbarClick="ToolbarClick" TValue="Employees"></GridEvents>
<GridColumns>
<GridColumn Type='ColumnType.CheckBox' Width="50"></GridColumn>
<GridColumn Field=@nameof(emp) HeaderText="S.No" IsPrimaryKey="true" ValidationRules="@(new { required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(emp.EmpCode) HeaderText="Emp Code" ValidationRules="@(new { required=true})" Width="120"></GridColumn>
<GridColumn Field=@nameof(emp.EmpName) HeaderText="Emp Name" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(emp.Department) HeaderText="Department" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(emp.Designation) HeaderText="Designation" TextAlign="TextAlign.Right" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
</div>
<Syncfusion.Blazor.Inputs.SfTextBox Value="@EmpCount"></Syncfusion.Blazor.Inputs.SfTextBox>
@code {
[Inject]
protected EmployeeService employeeService { get; set; }
protected List<Employees> empList;
SfGrid<Employees> Grid;
protected Employees emp =new Employees();
public string EmpCount ;
protected override async Task OnInitializedAsync()
{
await GetEmployee();
}
protected async Task GetEmployee()
{
empList = await employeeService.GetEmployeeList();
EmpCount = "4000"; // empList.Count.ToString();
}
public void ToolbarClick(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Grid_pdfexport")
{
this.Grid.PdfExport();
}
if (args.Item.Id == "Grid_excelexport")
{
this.Grid.ExcelExport();
}
if (args.Item.Id == "Grid_csvexport")
{
this.Grid.CsvExport();
}
}
}