When trying to remove columns or search after closing a modal I am unable to. I think it is doing some sort of initial search but is bugging out. My code is:
@page "/"
@using Data
@using Syncfusion.EJ2.Blazor.Grids
@using Syncfusion.EJ2.Blazor.Popups
@using Newtonsoft.Json;
@if (this.IsModalShown)
{
<EjsDialog id="dialog" header=@("modal") width="800px" isModal="true" allowDragging="true">
smt
<button @onclick=@(() => this.IsModalShown = false)>Close Modal</button>
</EjsDialog>
}
<EjsGrid @ref=this.defaultGrid DataSource=@this.gridData ShowColumnChooser="true" Toolbar="@(new List<string>() { "ColumnChooser", "Search" })"
AllowFiltering="true" CommandClicked="@CommandClickHandler">
<GridFilterSettings Type="@Syncfusion.EJ2.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridSearchSettings Fields="@(new string[] { "ShipCountry"})" Operator="contains" IgnoreCase="true"></GridSearchSettings>
<GridColumns>
<GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name"></GridColumn>
<GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="yMd"></GridColumn>
<GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2"></GridColumn>
<GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country"></GridColumn>
<GridColumn HeaderText="Actions" Commands=commands></GridColumn>
</GridColumns>
</EjsGrid>
@functions{
EjsGrid defaultGrid;
public bool IsModalShown { get; set; }
List<CommandModel> commands = new List<CommandModel>();
public List<OrdersDetails> gridData { get; set; }
protected override async Task OnInitAsync()
{
await base.OnInitAsync();
this.commands.Add(new CommandModel { Title = "Delete", ButtonOption = new CommandButtonOptions {IconCss="e-btn-sb-icons e-open-icon" , CssClass = "e-small e-round" } });
this.commands.Add(new CommandModel { Title = "Edit", ButtonOption = new CommandButtonOptions {IconCss="e-btn-sb-icons e-add-icon", CssClass = "e-small e-round" } });
this.gridData = OrdersDetails.GetAllRecords();
}
public void CommandClickHandler(CommandClickEventArgs args)
{
var selectedId = JsonConvert.DeserializeObject<OrdersDetails>(args.RowData.ToString()).CustomerID;
switch (args.CommandColumn.Title)
{
case "Edit":
IsModalShown = true;
this.Invoke(this.StateHasChanged);
break;
case "Delete":
this.DeleteCategory(selectedId);
break;
}
}
public void DeleteCategory(string id)
{
}
protected override void OnAfterRender()
{
base.OnAfterRender();
this.defaultGrid.GridLines = GridLine.Both;
}
}
P.S. I noticed that removing the line <GridSearchSettings Fields="@(new string[] { "ShipCountry"})" Operator="contains" IgnoreCase="true"></GridSearchSettings> fixes the issue but still I only want to search by the ShipCountry column.