my grid is not displaying data

@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();
        }
    }
}


1 Reply

VN Vignesh Natarajan Syncfusion Team July 7, 2020 07:22 AM UTC

Hi Cherry,  
 
Greetings from Syncfusion support.  
 
Query: “my grid is not displaying data” 
 
We have validated the reported issue by preparing a sample using your code example and we are not able to reproduce the reported issue at our end. Kindly download the sample from which we have prepared using 18.1.0.59.  
 
 
After referring the sample, if you are still facing the issue. kindly get back to us with following details.  
 
  1. Are you facing any issues or delay while fetching data from your database.
  2. Share your Syncfusion Nuget package version details.
  3. Share the details about the datasource count and its type (Iqueryable, IEnumerable)
  4. Share the error details by binding the OnActionFailure event of the Grid..     
  1. If possible try to reproduce the reported issue in provided sample and get back to us.
 
Above requested details will be helpful for us to validate the reported issue at our end and provide solution as soon as possible.  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon