-
Notifications
You must be signed in to change notification settings - Fork 32
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
MBGrid requirements #243
Comments
I'd like to add filtering to the wishlist. Ideally, this would include a set of filter methods for common datatypes (string and numerical data) and the ability to extend that with a custom filter dialog and method (I need to work out a nice way to integrate custom filtering, not sure about the syntax yet). [MS - 2020-09-05] Added requirement bullet with details TBD |
Thinking about the custom filter menu: The user should not be required to write a menu component and should not have to deal with how to open/close the menu. All they should provide is the content of the menu.
I'm fairly sure we can design it roughly like this, so that usage looks like: <Column Header="Column with customized filter">
<CustomFilterMenuContent>
@foreach (var item in context.Items)
{
<MTCheckbox Value="context.IsVisible(item)"
ValueChanged="(visible) => { UpdateFilter(context, item, visible); }"/>
}
</CustomFilterMenuContent>
</Column>
@code {
private List<TItem> my_visible_items = new List<TItem>();
private void UpdateFilter(ColumnFilterContext<TItem> context, TItem item, bool visible)
{
if (visible)
{
my_visible_items.Add(item);
}
else
{
my_visible_items.Remove(item);
}
// this is how we could update the filter: we replace the filter predicate
context.IsVisible = (i) => my_visible_items.Contains(i);
}
} This of course is a rather boring filter menu (simply listing all items? come on!) A more interesting one could be <Column Header="SomeValue">
<CustomFilterMenuContent>
<MTNumericDoubleField Value="threshold"
ValueChanged="(v) => {threshold = v; context.IsVisible = (i) => { i.SomeValue > threshold; }; } />
</CustomFilterMenuContent>
</Column>
@code {
private double threshold;
}
So I think the definition could be: public class ColumnFilterContext<TItem>
{
public IEnumerable<TItem> Items { get; } // to think about: is IEnumerable a good choice here?
public Func<TItem, bool> IsVisible { get; set; } = (_) => true; // default state is to have everything visible
} And for the column: public partial class Column
{
[Parameter] public string Header {get;set;}
[Parameter] public RenderFragment<ColumnFilterContext<TItem>> CustomFilterMenuContent {get;set;}
//...
} Disclaimer: none of this code is tested. It wasn't even compiled once, so might contain syntax errors and other issues. |
Is there anything in ASP.NET rc 1 that should be used to enhance a grid? E.g. Virtualize |
Closing as the path forward is in MBGridMT |
MBGrid Phase 1
MBGrid Phase 2
MBGrid Phase 3 Candidates
The text was updated successfully, but these errors were encountered: