The GridBlazor component installation is straightforward. Just follow these steps:
-
Create a new Blazor client-side solution using the Blazor WebAssembly App template
-
Install the GridBlazor nuget package v1.5.0 or lateron the client project.
-
Install the Microsoft.AspNetCore.OData nuget package v7.4.0 or later on the server project.
-
Add the following lines to the wwwroot/index.html file:
<link href="_content/GridBlazor/css/gridblazor.min.css" rel="stylesheet" /> <script src="_content/GridBlazor/js/gridblazor.js"></script>
These files will be loaded from the GridBlazor nuget package, so it is not necessary to copy it to you project.
-
If you are using Boostrap 3.x you will also need this line in the wwwroot/index.html file:
<link href="~/_content/GridBlazor/css/gridblazor-bootstrap3.min.css" rel="stylesheet" />
-
Add the OData endpoints in Startup.cs file of the server project:
app.UseEndpoints(endpoints => { endpoints.Select().Expand().Filter().OrderBy().MaxTop(100).Count(); endpoints.MapODataRoute("odata", "odata", EdmModel.GetEdmModel()); endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); });
It's important to enable
Select,Expand,Filter, andOrderByoperations at application level or at controller level. More information in the Microsoft OData dcoumentation.If you use another OData server implementation for the back-end you should read the providers documentation to configure the back-end project.