Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataAnnotation Null exception #293

Closed
borisdj opened this issue Jun 22, 2021 · 1 comment
Closed

DataAnnotation Null exception #293

borisdj opened this issue Jun 22, 2021 · 1 comment

Comments

@borisdj
Copy link
Contributor

borisdj commented Jun 22, 2021

Using info from Data_annotations I have tried to make Foo panel work but after click on menu 'Foo sample' we get an exception:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

that is thrown from line:
var client = new GridClient<Foo>(q => fooService.GetFooGridRows(q), query, false, "fooGrid", null, locale);
It seems to come from GridClient Constructor since all args are correct, fooService is loaded as well.

This is full stack:

This exception was originally thrown at this call stack:
    GridBlazor.CGrid<T>.ApplyGridSettings()
    GridBlazor.CGrid<T>.CGrid(System.Net.Http.HttpClient, string, System.Func<GridShared.Utility.QueryDictionary<Microsoft.Extensions.Primitives.StringValues>, GridShared.Utility.ItemsDTO<T>>, System.Func<GridShared.Utility.QueryDictionary<Microsoft.Extensions.Primitives.StringValues>, System.Threading.Tasks.Task<GridShared.Utility.ItemsDTO<T>>>, GridShared.Utility.IQueryDictionary<Microsoft.Extensions.Primitives.StringValues>, bool, System.Action<GridShared.IGridColumnCollection<T>>, System.Globalization.CultureInfo, GridShared.Columns.IColumnBuilder<T>)
    GridBlazor.CGrid<T>.CGrid(System.Func<GridShared.Utility.QueryDictionary<Microsoft.Extensions.Primitives.StringValues>, GridShared.Utility.ItemsDTO<T>>, GridShared.Utility.IQueryDictionary<Microsoft.Extensions.Primitives.StringValues>, bool, System.Action<GridShared.IGridColumnCollection<T>>, System.Globalization.CultureInfo, GridShared.Columns.IColumnBuilder<T>)
    GridBlazor.GridClient<T>.GridClient(System.Func<GridShared.Utility.QueryDictionary<Microsoft.Extensions.Primitives.StringValues>, GridShared.Utility.ItemsDTO<T>>, GridShared.Utility.QueryDictionary<Microsoft.Extensions.Primitives.StringValues>, bool, string, System.Action<GridShared.IGridColumnCollection<T>>, System.Globalization.CultureInfo, GridShared.Columns.IColumnBuilder<T>)
    BlazorGrid.Pages.FooSample.OnParametersSetAsync() in FooSample.razor
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

@borisdj borisdj changed the title DataAnnotation Null exception and Doc Fix DataAnnotation Null exception Jun 22, 2021
@borisdj
Copy link
Contributor Author

borisdj commented Jun 22, 2021

I've loaded the Source and have managed to find the issue, null was thrown in CGrid.cs on line:
Pager.PageSize = opt.PageSize;
This happend because of attribute [GridTable(PagingEnabled = true, PageSize = 20)]
And it seems that in CGrid constructor line Pager = new GridPager(query); is called after call to ApplyGridSettings();
So the fix is simple to move it before.

heinleit added a commit to heinleit/Grid.Blazor that referenced this issue Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant