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

GridHeaderComponent is null when I tried to use a custom filter. #87

Closed
pcecamacho opened this issue Feb 5, 2020 · 6 comments
Closed

Comments

@pcecamacho
Copy link

Hello
I am following the manual help to configure a custom filter.
https://github.com/gustavnavar/Grid.Blazor/blob/master/docs/blazor_client/Creating_custom_filter_widget.md

It is working fine displaying the options in the filter but when I apply the filter I get a null exception for "GridHeaderComponent" in the following method.

protected async Task ApplyButtonClicked()
{
await GridHeaderComponent.AddFilter(new FilterCollection(GridFilterType.Equals.ToString("d"), _filterValue));
}

Please, how I should be initializing this "GridHeaderComponent"?

@gustavnavar
Copy link
Owner

GridHeaderComponent must be cascading parameter. You have to use this annotation when defined:

    [CascadingParameter(Name = "GridHeaderComponent")]
    private GridHeaderComponent<T> GridHeaderComponent { get; set; }

@pcecamacho
Copy link
Author

ok, I did that but no work yet for me. Let me explain the code:

  1. I have the CustomersFilterComponent.razor file in this, the GridHeaderComponent was defined as:
[CascadingParameter(Name = "GridHeaderComponent")]
private GridHeaderComponent<T> GridHeaderComponent { get; set; } 
  1. The main razor page, the grid is define

<GridComponent @ref="GridComponent" T="TransactionData" Grid="@this.gridInstance" OnRowClicked="@RowClickedAsync" CustomFilters="@_customFilters"></GridComponent>

in code section

private IQueryDictionary<Type> _customFilters = new QueryDictionary<Type>();

protected override async Task OnParametersSetAsync()
 {
            await this.GetGridInformationAsync();
 }

private async Task GetGridInformationAsync()
{
	Action<IGridColumnCollection<TransactionData>> columns = c =>
	{
		c.Add(o => o.InputTime).Titled("Date/Time").Format("{0:dd MMM yyyy hh:mm:ss tt}");
		c.Add(o => o.SourceId).Titled("Source ID").Filterable(true).SetFilterWidgetType("CompanyNameFilter");

		var gridButtons = new List<GridButtonParams>
		{
			new GridButtonParams
			{
				.....
				OnClickActionToExecute = this.ShowModalSummary,
			},
		};

		c.Add().RenderComponentAs<GridActions<TransactionData>>(null, null, gridButtons);
	};

	var query = new QueryDictionary<StringValues>
	{
		....
	};

	var client = new GridClient<TransactionData>(q => this.Service.GetTransactionDataGridRows(columns, q), query, false, "TransactionDataGrid", columns)
		.ChangePageSize(true)
		.Filterable()
		.......

	this._customFilters.Add("CompanyNameFilter", typeof(CustomersFilterComponent<TransactionSummary>));

	this.gridInstance = client.Grid;

	// Set new items to grid
	this.loadGridDataTask = client.UpdateGrid();
	await this.loadGridDataTask;
}

With this code I get the NULL exception that I mentioned,

Thank you in advance for your help

@gustavnavar
Copy link
Owner

Can you send me the full main and CustomersFilterComponent razor pages?

gustavnavar added a commit that referenced this issue Feb 8, 2020
@gustavnavar
Copy link
Owner

I don't see anything wrong in your code. But I've done some changes for cascading parameter in GridBlazor and GridMvcCore projects.

I think it will work fine if you update GridBlazor and GridMvcCore to versions 1.3.17 and 2.11.14.

@pcecamacho
Copy link
Author

Right, Thank you, This is working fine.

gustavnavar added a commit that referenced this issue Feb 22, 2020
* Update documentation

* Add CRUD support

* Add Guid foreign keys with CRUD

* Update CRUD documentation

* Add ability to change the page size

* Add ability to change the page size

* Add keyboard navigation of the grid (#32)

* Grouping error when column value is null (#41)

* Improvements to filtering (#35)

* Update documentation 3.1

*  Update documentation 3.1

* Fixed Razor compilation errors when using .NET Core 3.1

* Add Css classes override for most important grid elements

* Added HasConstraint property to GridColumnBase

* Reset cached items count value when collection changes

* Fix gridblazor.min.css issue

* Fix compilation error in more components

* Fix drag error on Firefox and Edge (#41)

* Group by property, then sort groups by expression (#33)

* Group by property, then sort groups by expression (#33)

* Add HasConstraint property to GridColumn for MVC

* Provide overloaded RenderComponentAs() with async callbacks(#38)

* Update documentation

* Upgrade to .Net Core 3.1

* Fix issue when collapsing a group (#50)

* Use partial classes for razor pages

* Update documentation

* Update documentation

* Update documentation

* updated readme

* Changed page navigation to ctrl +[Right/Left Arrow key] instead of just Right/Left Arrow keys

* Updated Documentation for Keyboard Navigation commands

* Added Ctrl requirement for Home and End keys to navigate to first and last pages respectively

* Revert "updated readme"

This reverts commit 8dfefac.

* Added multi select capability

* added vscode directory to gitignore

* Updated documentation

* Added Selected Items propery

* updated documentation

* Add clear all filters functionality

* Update localization documentation

* Add multiselectable and Norwegian translation

* Fix bug #56

* Change keyboard modifier key

* Change keyboard modifier key

* Added type="button" to all <button> with no specified type to avoid making them a type="submit" buttons

* Remove Newtonsoft.Json dependency

* Update documentation

* Fix issue #61 and new GridMvcCore string resources

* Update package versions

* Correct parameter assignation

* Modify the  ChangeBool to reflect changes to value false in variable

* Set Id of the new ColumnOrderValue to the max Id plus 1

* Fix issue #63

* Update documentation

* Add list filters

* Add filters on hidden columns and grid events

* Added Turkish Language

* Added Turkish Language

* Add filters on hidden columns and grid events

* Validate that FieldName is not null  in case not mapped column exist

* Add Guid filter

* Validate that FieldName is not null in case not mapped column exist

* Update documentation

* Add method ReadonlyOnUpdate to columns

* Added GridCellCssClass
Added GridItemsCountCssClass

* Hide ReadonlyOnUpdate columns on create page

* Update documentation

* Add NotEqual filter (#79)

* Fix GridMvcCore Ajax currentPage value type

* Update Blazor demos

* Update Blazor demos

* Hide other filter widget when opening a filter #81

* ReadOnUpdate fields should not be hidden on Create.

* Consider case when both ReadOnlyOnUpdate and CrudHidden are used.

* Blazor WA 3.2.0 Preview 1 support

* Update GridBlazor version

* Allow ICustomGridComponent<> type argument to be interface of Grid data type. Addresses issue #53

* Minor fixes for GridBlazor filters and GridMvc pager

* Fix isssue #89

* Fix isssue #87

* Update GridBlazor in MVC demo

* Add Bootstrap 3.x css

* Add Czech translation

* Add DateTime picker and custom comparer sort

* Add nested CRUD

* punctual crud visibility

added punctual visibility for each CRUD mode.

Co-authored-by: Gustavo Navarro <30131949+gustavnavar@users.noreply.github.com>
Co-authored-by: Serhii Yolkin <serhii.yolkin@gmail.com>
Co-authored-by: Deval Ringwala <ringwala@lucasware.com>
Co-authored-by: Ricardo Pacheco <ricardo.pacheco.roldan@gmail.com>
Co-authored-by: İSMAİL KÖSE <kyzaghan@ismailkose.com.tr>
Co-authored-by: timbze <35117769+timbze@users.noreply.github.com>
@AlexeyBoyko
Copy link

Hello, I am facing quite the same problem at the moment, despite using the latest version of GridBlazor (3.5.2). Could you please check if the issue had resumed at some point after version 1.3.17 (where it was obviously fine)?

rgentry09 added a commit to rgentry09/ERP-ASP.NET that referenced this issue Jul 10, 2023
dev0926 added a commit to dev0926/gridNET that referenced this issue Feb 21, 2024
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

3 participants