Skip to content

Commit d995a59

Browse files
docs(Grid): Fix broken link and polish EditorTemplate article (#3114)
Co-authored-by: Dimo Dimov <[email protected]>
1 parent cc8cb09 commit d995a59

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

components/grid/templates/editor.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ If you need more complex logic inside the editor template, compared to simple da
2020

2121
>tip The Editor Template works in all edit modes (Inline, Popup, InCell). Before using it with InCell mode, review the [pertinent notes](slug:grid-editing-incell#editor-template).
2222
23-
When an input receives an `EditContext` (usually comes down as a cascading parameter), the framework also requires a `ValueExpression`. If you use two-way binding (the `@bind-Value` syntax), the `ValueExpression` is deducted from there. However, if you use only the `Value` property, you have to pass the `ValueExpression` yourself. This is a lambda expression that tells the framework what field in the model to update. The following sample demonstrates how to achieve that. You can also check the [Requires a value for ValueExpression](slug://common-kb-requires-valueexpression) knowledge base article for more details.
23+
When an input receives an `EditContext` (usually as a cascading parameter), the framework also requires a `ValueExpression`. If you use two-way binding (the `@bind-Value` syntax), the `ValueExpression` is deducted from there. However, if you use only the `Value` parameter, you have to pass the `ValueExpression` explicitly. This is a lambda expression that tells the framework what property of the model to use for validation. The following sample demonstrates how to achieve that. You can also check the [Requires a value for ValueExpression](slug:common-kb-requires-valueexpression) knowledge base article for more details.
2424

2525
<div class="skip-repl"></div>
2626
````RAZOR
2727
<EditorTemplate>
2828
<TelerikTextBox Value="@myModel.MyField"
29+
ValueChanged="@( (string newValue) => myModel.MyField = newValue )"
2930
ValueExpression="@( () => myModel.MyField )">
3031
</TelerikTextBox>
3132
</EditorTemplate>
3233
3334
@* Applies to the other input type components as well *@
3435
````
3536

36-
3737
**In this article:**
3838

3939
* [Notes](#notes)
@@ -46,39 +46,30 @@ When an input receives an `EditContext` (usually comes down as a cascading param
4646

4747
* @[template](/_contentTemplates/common/inputs.md#edit-debouncedelay)
4848

49-
* The Grid row creates an `EditContext` and passes it to the `EditorTemplate`. You can read more about it in the [**Notes** section of the Editing Overview](slug:grid-editing-overview#notes) article.
50-
5149
* We recommend casting the Editor Template context to your model and storing it in a local or a dedicated global variable. Do not share a global variable within multiple templates, like column (cell) template and editor template. Variable sharing can lead to unexpected behavior.
5250

53-
* Direct casting of the `context` can make the data binding not work properly.
54-
55-
56-
>caption Not recommended: direct casting. Binding does not work properly.
51+
* Direct casting of the `context` can make two-way data binding not work properly.
5752

58-
<div class="skip-repl"></div>
53+
>caption Not recommended: direct casting with two-way parameter binding
5954
60-
````RAZOR
55+
````RAZOR.skip-repl
6156
<EditorTemplate>
6257
<TelerikTextArea @bind-Value="@((Product)context).Description" />
6358
</EditorTemplate>
6459
````
6560

66-
>caption Recommended: cast the context to your model type and store it in a variable. Binding works as expected.
61+
>caption Recommended: cast the context in advance
6762
6863
<div class="skip-repl"></div>
6964

7065
````RAZOR
7166
<EditorTemplate>
7267
@{
73-
EditedProduct = context as Product;
68+
var editProduct = (Product)context;
7469
75-
<TelerikTextArea @bind-Value="@EditedProduct.Description" />
70+
<TelerikTextArea @bind-Value="@editProduct.Description" />
7671
}
7772
</EditorTemplate>
78-
79-
@code{
80-
private Product EditedProduct { get; set; }
81-
}
8273
````
8374

8475
## Examples

0 commit comments

Comments
 (0)