I am having a problem where the ColumnChooser will show for a very brief (<1 sec) time. I don't actually see it, I just see the .css change from close to open and then right back. All of the other Grid functions work as expected. This very same code in this project has worked in the past. I am unclear what is causing the problem. Thank you in advance for your help.
I have the following Code:
//Component that holds the Open Column Chooser Button
<SearchBarComponent OnSearch="HandleSearch" OnExport="ExcelExport" OnAddRecord="HandleAddRecord" OnShow="HandleShow" OnPrint="HandlePrint" />
<br/>
<SfTab>
<TabItems>
<TabItem>
<HeaderTemplate>
<div class="e-title">Active</div>
<div style="padding: 0 4px; margin-left: 2px; background-color: var(--button-primary); color: var(--button-primary-text)">@peopleCount</div>
</HeaderTemplate>
<ContentTemplate>
<div style="height: calc(100vh - 15rem);" class="grid-container">
<a name="target"></a>
<span class="error">@ErrorDetails</span>
<SfGrid DataSource="people" TValue="Person" ID="StudentGrid" @ref="DefaultGrid" AllowPaging="true" AllowSorting="true" AllowExcelExport="true" AllowReordering="true"
ShowColumnMenu="true" ColumnMenuItems="@menuItems" ShowColumnChooser="true" RowHeight="70" Height="100%" Toolbar="@toolbarItems">
<GridEvents OnRecordDoubleClick="RecordDoubleClickHandler" TValue="Person" OnActionFailure="@ActionFalure"></GridEvents>
<GridPageSettings PageSize="50" PageSizes="new int[] {50, 100, 150, 200}"></GridPageSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" Mode="EditMode.Dialog">
// Grid Editor Template
</GridEditSettings>
<GridColumns>
// Grid Column Templates
</GridColumns>
</SfGrid>
</TabItem>
// More (Empty) Tabs
</TabItems>
</SfTab>
</div>
//Send Email Pop Up Form
<EmailDialogComponent @ref="emailDialog"></EmailDialogComponent>
@code {
private IEnumerable<Person> people;
private string ErrorDetails = "";
private SfGrid<Person> DefaultGrid;
public string[] toolbarItems = new[] {"ColumnChooser"}; //Only to see if this would work
private int peopleCount = 0;
private EmailDialogComponent emailDialog;
private string[] menuItems = new string[] {"SortAscending", "SortDescending", "AutoFit", "AutoFitAll", "ColumnChooser"};
protected override async Task OnInitializedAsync()
{
base.OnInitialized();
people = await Http.GetFromJsonAsync<List<Person>>("api/people");
peopleCount = people.Count();
}
private void HandleSearch(string filter)
{
DefaultGrid.Search(filter);
}
private async Task ExcelExport()
{
await DefaultGrid.ExcelExport();
}
private async Task HandleAddRecord()
{
await DefaultGrid.AddRecord();
}
private async Task HandleShow()
{
// int height, width;
// var dimension = await Service.GetDimensions();
// height = dimension.Height;
// width = dimension.Width;
//await DefaultGrid.OpenColumnChooser(width - 550, 50);
await DefaultGrid.OpenColumnChooser(200, 50); //Changed to make sure it was on the page - hasn't helped
}
private async Task HandlePrint()
{
await DefaultGrid.Print();
}
private void RecordDoubleClickHandler(RecordDoubleClickEventArgs<Person> args)
{
NavigationManager.NavigateTo("/profile/" + args.RowData.Id);
}
private void Navigate(Person person)
{
NavigationManager.NavigateTo("/profile/" + person.Id.ToString());
}
private void OpenDialog(Person person)
{
emailDialog.OpenDialog(person);
}
private void ActionFalure(FailureEventArgs eventArgs)
{
ErrorDetails = eventArgs.Error.Message;
}
}