Hi,
I'm trying to create a custom EditForm component by i just can't get it working.
The TelerikTextBox loses focus after every keystroke and also never causes the EditContext to getb into a modified start.
My model look like:
public
class
MyModel
{
public
string
Code {
get
;
set
; }
public
string
Name {
get
;
set
; }
}
The EditForm is split into a razor and a razor.cs file:
@inherits MyEditFormBase
<
EditForm
EditContext
=
"@MyEditContext"
>
<
CascadingValue
Name
=
"EditContext"
Value
=
"@MyEditContext"
>
@ChildContent(MyEditContext)
</
CascadingValue
>
</
EditForm
>
<
TelerikButton
Title
=
"Ok"
OnClick="(() => Console.WriteLine(MyEditContext.IsModified()))" />
public
class
MyEditFormBase : ComponentBase
{
public
EditContext MyEditContext;
[Parameter]
public
RenderFragment<EditContext> ChildContent {
get
;
set
; }
[Parameter]
public
MyModel Value {
get
;
set
; }
protected
override
Task OnParametersSetAsync()
{
MyEditContext =
new
EditContext(Value);
return
base
.OnParametersSetAsync();
}
}
And finally to apply the MyEditForm i'm using this:
<
MyEditForm
Value
=
"@Value"
>
<
TelerikTextBox
Value
=
"@Value.Code"
ValueExpression="@(() => Value.Code)"
ValueChanged="@((string s) => Value.Code = s)" />
</
MyEditForm
>
@code {
public MyModel Value { get; set; } = new MyModel();
}
It all looks relatively simple, but i can't figure out how to make it work properly.
Am i missing something, or am i trying to use the Telerik controls in a way they can't handle?
Regards,
Gerrit