Search results

Getting Started

This section briefly explains about how to include a Listview in your Blazor client-side application. You can refer Getting Started with Syncfusion Blazor for Client-Side in Visual Studio 2019 Preview page for the introduction and configuring the common specifications.

Importing Syncfusion Blazor component in the application

  1. Install Syncfusion.EJ2.Blazor NuGet package to the application by using the NuGet Package Manager. Please ensure to check the Include prerelease option.
  2. You can add the client-side resources through CDN or local npm package in the <head> element of the ~/wwwroot/index.html page.
<head>
    <link href="https://cdn.syncfusion.com/ej2/17.3.29/material.css" rel="stylesheet" />
    <script src="https://cdn.syncfusion.com/ej2/17.3.29/dist/ej2.min.js"></script>
</head>

Adding component package to the application

Open ~/_Imports.razor file and import the Syncfusion.EJ2.Blazor.Lists packages.

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Lists

Adding ListView component to the application

Add the Syncfusion Essential JS 2 Listview component in any web page (razor) in the Pages folder. For example, the Listview component is added in the ~/Pages/Index.razor page.

@using Syncfusion.EJ2.Blazor.Lists
<EjsListView DataSource="@Data">
    <ListViewFieldSettings Id="Id" Text="Text"></ListViewFieldSettings>
</EjsListView>

@code
{private DataModel[] Data =
     {
            new DataModel { Text = "ArtWork", Id = "list-01" },
            new DataModel { Text = "Abstract", Id = "list-02" },
            new DataModel { Text = "Modern Painting", Id = "list-03" },
            new DataModel { Text = "Ceramics", Id = "list-04" },
            new DataModel { Text = "Animation Art", Id = "list-05" },
            new DataModel { Text = "Oil Painting", Id = "list-06" }
    };

    class DataModel
    {
        public string Text { get; set; }
        public string Id { get; set; }
    }
}

Run the application

After successful compilation of your application, simply press F5 to run the application.

Output be like the below.

Listview Sample

See Also