Declined
Last Updated: 25 Jan 2023 16:08 by Peter
Peter
Created on: 24 Jan 2023 15:58
Category: UI for Blazor
Type: Feature Request
0
Add Field parameter to data entry components.

In the TelerikForm component, you have "FormItem" with a string parameter of Field and from the string, you somehow bind the data to that field.

For other components, we must use the @bind-Value to get this 2-way binding.

I would like to request the "Field" parameter for more controls like TelerikTextBox where we can bind using the string name of the field like we do in FormItem.

So instead of:

<TelerikTextBox @bind-Value="@customer.CustomerName" />

we would be able to do this:

<TelerikTextBox Field="CustomerName" />

or this:

<TelerikTextBox Field="customer.CustomerName" />

I would suspect that this would only work inside an EditContext.

Peter

2 comments
Peter
Posted on: 25 Jan 2023 16:08

Okay, I have an alternative solution, perhaps this works already but there is just no documentation for it. 

If we expose the contents of the Field inside of a templated FormItem.

Something like this:

<FormItem Field="customer.CustomerName">
         <Template>
             <label for="country">Customer Name:</label>
             <TelerikTextBox @bind-Value="@context.Value" />
         </Template>
</FormItem>

That way we could have access to the variable inside the template.  It would be a generic solution that would work for all controls just by exposing the target of the FormItem.

Peter

ADMIN
Svetoslav Dimitrov
Posted on: 25 Jan 2023 13:16

Hello Peter,

The Field parameter is added to components that are meant to be bound to a model or can receive a model through a parameter, such as the TItem for the Grid. Let me provide a short list of components that have the Field parameter:

  • GridColumn (Grid) - bound to a model through the Data parameter (List<Model>) or the TItem parameter. The same extends to components such as the TreeList, and Gantt
  • FormItem (Telerik Form) - bound to a model through the Model parameter or the EditContext parameter.

The TextBox is designed to be bound to a string variable and this is the most common scenario. The Field parameter is useful only when the component is used in a form or a component that has EditContext as you rightfully mentioned. However, it will be a substitute, of a sort, for the @bind-Value mechanism that works in specific scenarios - when an EditContext is present. 

Based on that, our belief is that this is best implemented by the application, where our input component (TextBox, NumericTextBox, CheckBox, etc) is wrapped by a custom component that executes the necessary business logic.

That being said, I am marking this feature request as "Declined".

Regards,
Svetoslav Dimitrov
Progress Telerik

Learn about the important changes coming in UI for Blazor 4.0 in January 2023!