I'm just trying out my first data grid, and am hitting a problem. Everything appears to run okay, but at the end I have a page with no grid visible. I'm doubtless missing something obvious, but despite routing through the demos I'm not finding it. Below are my startup code and the component I'm working on - I'm using server side blazor, by the way:
public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => options.EnableEndpointRouting = false).SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0); services.AddRazorPages(); services.AddScoped<IClaimsTransformation, ClaimsTransformer>(); services.AddScoped<ICustomerService, CustomerService>(); services.AddScoped<IMeterService, MeterService>(); services.AddScoped<ITariffService, TariffService>(); services.AddScoped<IContractService, ContractService>(); services.AddScoped<IAdminService, AdminService>(); services.AddScoped<IReadingsService, ReadingsService>(); services.AddDbContext<Model>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Transient); services.AddIgniteUIBlazor(typeof(DataGridModule)); services.AddBlazoredToast(); services.AddServerSideBlazor(); services.AddSingleton(Configuration.GetSection("AppConfig").Get<AppConfig>()); services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme); services.AddAuthorization(); }
@page "/readinglists" <AuthorizeView Context="secCont"> <Authorized> <h3>Reading Lists</h3> <DataGrid Height="100%" Width="100%" @ref="GridLists" DataSource="Data" AutoGenerateColumns="false" GroupHeaderDisplayMode="DataSourceSectionHeaderDisplayMode.Combined" > <TextColumn Field="Area" HeaderText="Area" Width="250" /> <TextColumn Field="ListLabel" HeaderText="Period"></TextColumn> <DateTimeColumn Field="ReadingDate" HeaderText="Reading Date"/> </DataGrid> </Authorized> <NotAuthorized> <PageRestricted></PageRestricted> </NotAuthorized> </AuthorizeView> @code { private DataGrid gridLists; private DataGrid GridLists { get=>gridLists; set { gridLists = value; OnGridCreated(); StateHasChanged(); } } private void OnGridCreated() { var loc = new ColumnGroupDescription { Field = "Location", DisplayName = "Location" }; GridLists.GroupDescriptions.Add(loc); } }
namespace Utilities.Pages.Readings { public partial class ReadingLists { [Inject] public IIgniteUIBlazor IgniteUIBlazor { get; set; } [Inject] public IReadingsService ReadingsService { get; set; } private IEnumerable<ReadingListSummaryData> Data { get; set; } = new List<ReadingListSummaryData>(); protected override async Task OnInitializedAsync() { try { DataGridModule.Register(IgniteUIBlazor); GridColumnOptionsModule.Register(IgniteUIBlazor); Data = new List<ReadingListSummaryData>() { new ReadingListSummaryData() {Area="Birkenhead", Frequency=BillingFrequency.Monthly, ReadingDate=DateTime.Today.AddDays(6) }, new ReadingListSummaryData() {Area="Birkenhead", Frequency=BillingFrequency.Monthly, ReadingDate=DateTime.Today.AddDays(-24) }, new ReadingListSummaryData() {Area="Birkenhead", Frequency=BillingFrequency.Quarterly, ReadingDate=DateTime.Today.AddDays(16) }, new ReadingListSummaryData() {Area="Central", Frequency=BillingFrequency.Monthly, ReadingDate=DateTime.Today.AddDays(-6) }, new ReadingListSummaryData() {Area="City Lofts", Frequency=BillingFrequency.Monthly, ReadingDate=DateTime.Today.AddDays(-14) }, new ReadingListSummaryData() {Area="City Lofts", Frequency=BillingFrequency.Quarterly, ReadingDate=DateTime.Today.AddDays(-52) } }; Ready = true; await Task.CompletedTask; } catch (Exception ex) { ErrorText = $"Problem fetching reading list data: {ex.Message}"; } } } }
Ah, never mind, it was a silly mistake - forgot to add the javascript link to the host file! I still had the script reference from the alpha release in there, so didn't notice
Hello Kevin,
Thank you for your post(s) on this matter. I am glad you were able to resolve the issue you were seeing and get the Blazor DataGrid to show up.
Please let me know if you have any other questions or concerns on this matter.
Thanks Andrew. As you can probably see from my other posts, I've ran into a few other issues, one of which is probably a show stopper for us. Its a shame as I was really hoping to switch to your grid as it looks and performs better than what I'm using now, but it just doesn't feel entirely ready yet :-(
Have you got any timeline for releasing updates to the components?
While I do not have a direct timeline for exact fixes for the Ignite UI for Blazor product, I have spoken with our product management team and we are targeting sometime in November for the next Blazor update.