Comments (3)
Yes, you can use the MetaConfiguration in general for customize property and behaviours of your model or sub model independent if a dialog from collection edit is used or the form directly.
Here for exampel if UserModel should be configured to use a password field for the password property
public class UserModelMetaConfiguration: IObjectMetaConfiguration<UserModel>
{
public Task ConfigureAsync(ObjectEditMeta<UserModel> meta)
{
meta.Properties(m => m.FirstName, m => m.LastName)
.WrapInMudItem(mudItem => mudItem.xs = 6);
meta.Property(m => m.Password)
.RenderWith<MudTextField<string>, string>(field => field.Value, field =>
{
field.InputType = InputType.Password;
})
.WrapInMudItem(mudItem => mudItem.xs = 12);
return Task.CompletedTask;
}
}
For size or dialog options in general you can set them only to MudExCollectionEdit. That means if the collection is used inside of an editable model you need to specify this as well in the meta configuration, but I will add a possibility to forward from MudExObjectEdit. However you can do currently with a MetaConfoguration as well.
For Example if you have a class like this with a collection of Users in this case
public class SomeClassWithUser
{
public List<UserModel> Users { get; set; }
You can create you meta config like this
public class SomeClassWithUserMetaConfiguration : IObjectMetaConfiguration<SomeClassWithUser>
{
public Task ConfigureAsync(ObjectEditMeta<SomeClassWithUser> meta)
{
DialogOptionsEx dialogOptionsEx = new DialogOptionsEx()
{
MaximizeButton = true,
CloseButton = true,
FullHeight = true,
CloseOnEscapeKey = true,
MaxWidth = MaxWidth.Medium,
FullWidth = true,
DragMode = MudDialogDragMode.Simple,
Animations = new[] { AnimationType.SlideIn },
Position = DialogPosition.CenterRight,
DisableSizeMarginY = true,
DisablePositionMargin = true
};
meta.Properties(m => m.Users)
.RenderWith<MudExCollectionEditor<UserModel>, ICollection<UserModel>>(ce => ce.Items)
.WithAdditionalAttribute(nameof(MudExCollectionEditor<UserModel>.DialogOptions), dialogOptionsEx);
return Task.CompletedTask;
}
}
from mudblazor.extensions.
Well but it works partly for me.
I have a generic object that I don't know about.
in the Configure(ObjectEditMeta meta) method I apply changes to all my properties, if I change the type of password, fix the label and more. When I encounter a property of type ICollection I apply the modification of the dialog you recommended, but the properties that are displayed in the dialog I don't know how to modify.
How can I do?
Best regards
from mudblazor.extensions.
That should not be a problem. You also can configure the meta. You dont need to use the Configure Method on the MudExObjectEdit component. You can also just implement the IObjectMetaConfiguration interface.
What I'm for example doing is this. I have a base Config for my Dto's
public abstract class BaseDtoMetaConfiguration<T, TId> : IObjectMetaConfiguration<T> where T : IDtoBase<TId>
{
public virtual Task ConfigureAsync(ObjectEditMeta<T> meta)
{
meta.Property(x => x.Id)
.WithAdditionalAttributes(true,new KeyValuePair<string, object>(nameof(MudBaseInput<TId>.Disabled), true))
.WithOrder(0);
if (meta.Value.IsNew)
meta.Property(x => x.Id).Ignore();
meta.Property(x => x.IsNew).Ignore();
meta.WrapEachInMudItem(i =>
{
i.xs = 12;
i.md = 6;
});
return Task.CompletedTask;
}
}
And then for all my Dtos I create a small config.
public class IcdDtoMetaConfiguration: BaseDtoMetaConfiguration<IcdDto, int>
{
public override Task ConfigureAsync(ObjectEditMeta<IcdDto> meta)
{
meta.Property(dto => dto.Name).WrapInMudItem(i => i.md = 12);
meta.Property(dto => dto.IcdVersion).Ignore();
return base.ConfigureAsync(meta);
}
}
And then its independent where and why you model is rendered later on, your config will work.
Also you can configure all Collections inside of a MetaConfig. Independent if youre using the interface or the delegate on the component you can just query your properties and do something for all collections.
private static bool IsCollection(Type type)
=> type.IsGenericType && type.GetGenericTypeDefinition() == typeof(ICollection<>) || type.GetInterfaces().Any(IsCollection);
meta.AllProperties.Where(oem => IsCollection(oem.PropertyInfo.PropertyType)).RenderWith(...);
And if all of this doesnt help, you can also Registering global type defaults with the static class RenderDataDefaults.
RenderDataDefaults.RegisterDefault<ICollection<string>, MudExCollectionEditor<string>>(f => f.Items);
Then all ICollections of string will be rendered with the desired configuration if no other meta config is provided.
from mudblazor.extensions.
Related Issues (20)
- [Bug]: dialog flashes in middle of screen and reappears with animation HOT 2
- [Bug]: ReflectionTypeLoadException with Mudblazor 6.17.0 HOT 3
- [Bug]: Unable to add spaces in filter bar of MudExSelect HOT 5
- [Bug]: Required and Required Error in MudExSelect
- Create MudExGrid as dockingcontrol like gridstack.js
- Create speechtotext button
- MudExDialog Position and Size properties HOT 2
- Having ScrollSpy would be nice HOT 2
- Dialog cancel event handler - cancable event HOT 1
- File Upload Issue in MudExObjectEditDialog HOT 1
- [Bug]: Unable to reproduce MudExFileDisplayZip example HOT 2
- [Bug]: ReflectionTypeLoadException with Mudblazor 7.0.0 HOT 2
- [Bug]: Value cannot be null. (Parameter 'jsRuntime') HOT 2
- [Bug]: Unable to load one or more of the requested types HOT 2
- [Bug]: MudExDialogService.ShowFileDisplayDialog error/unexpected behaviour on specific data types HOT 20
- [Bug]: Clicking backdrop when 'BackdropClick = false' still closes dialog HOT 3
- [Bug]: MudExDialogService does not implement new HOT 5
- Support for other browsers than Chrome (and without add-ins)? HOT 1
- [Bug]: SixLabors.ImageSharp minimum package version upgrade due to security vulnerability HOT 3
- Code Editor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mudblazor.extensions.