Skip to content

Commit

Permalink
DataGrid: Fix filter and several other bugs (#4942, #4924, #4921, #4551
Browse files Browse the repository at this point in the history
…) (#5093)
  • Loading branch information
tjscience committed Aug 20, 2022
1 parent b559b3d commit 0e2fc1e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
@@ -0,0 +1,32 @@
@namespace MudBlazor.UnitTests.TestComponents
<MudPopoverProvider></MudPopoverProvider>

<MudDataGrid Items="@_items" Filterable="true">
<Columns>
<Column T="Model" Field="@nameof(Model.Id)" />
<Column T="Model" Field="@nameof(Model.Name)" />
</Columns>
</MudDataGrid>

@code {
private IEnumerable<Model> _items = new List<Model>()
{
new Model("B"),
new Model("A"),
new Model("C"),
new Model("C")
};

public class Model
{
public Guid Id { get; set; }
public string Name { get; set; }

public Model(string name)
{
Id = Guid.NewGuid();
Name = name;
}
}

}
9 changes: 9 additions & 0 deletions src/MudBlazor.UnitTests/Components/DataGridTests.cs
Expand Up @@ -2612,5 +2612,14 @@ public async Task DataGridCellContextTest()
cell.cellContext.Actions.SetSelectedItem(true);
cell.cellContext.IsSelected.Should().Be(true);
}

[Test]
public async Task DataGridSequenceContainsNoElementsTest()
{
var comp = Context.RenderComponent<DataGridSequenceContainsNoElementsTest>();
var dataGrid = comp.FindComponent<MudDataGrid<DataGridSequenceContainsNoElementsTest.Model>>();

// This test will result in an error if the 'sequence contains no elements' issue is present.
}
}
}
2 changes: 1 addition & 1 deletion src/MudBlazor/Components/DataGrid/Column.cs
Expand Up @@ -279,7 +279,7 @@ protected override void OnInitialized()
Field = Field,
FieldType = FieldType,
Title = Title,
Operator = operators.First()
Operator = operators.FirstOrDefault()
};
}

Expand Down

0 comments on commit 0e2fc1e

Please sign in to comment.