4 Answers, 1 is accepted
Hi Frans,
You could use the items.label option to define the label of the field. You could find an example in the Demo linked here.
If you inspect the text before each item you will see that a <label/> element is rendered. Here is a screencast where you could see the label element rendered for the Password field in the Basic usage Form Demo.
I hope the provided information will be helpful.
Regards,
Neli
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hi Neli,
I understand. But this is a clientside solution.
I want this supported serverside in a easy way like for all the other control items. Something like ....Label("MyLabel");
best regards,
Martin
Hi Frans,
Please excuse me in the last reply I sent you a link to the jQuery Demos. Here you will find a link to the UI for ASP.NET MVC demos. Below you will find an example of how the label could be configured when using the server-side wrappers:
i.Add()
.Field(f => f.FirstName)
.Label(l => l.Text("First Name:"));
If you need to use a value from the model, you can pass it as in the example below:
.Label(l => l.Text(@Model.FirstName));
I would also encourage you to cast a vote for the Feature request linked below for adding support for text of the labels in the Form to be retrieved from DataAnnotations:
Let me know in case you have additional questions on the matter.
Regards,
Neli
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.
Thanks Neli,
I upvoted the feature request, I think it is so basic it should just be there.
The solution above is not a solution for me, so I tried to make a quick hack for this problem:
// Render a textbox, and style it as a label (will be posted to server)
items.Add()
.Field(propInfo.Name)
.Label(propInfo.Label)
.EditorTemplate($"<input id=\"{propInfo.Name}\" name=\"{propInfo.Name}\" type=\"text\" style=\"border: 0px;background:transparent;caret-color: transparent;outline:none;padding:5 0 0 0;\" readonly /> ");
Of course its better to put the css not inline, but this is just to demonstrate.
Hi Frans,
Thank you very much for sharing the solution that is suitable for your scenario with the community. I am sure it will be helpful to the other users in the Forum.
Thank you also for voting for the Feature request. We will keep monitoring the demand and depending on the votes the issue collects we might consider the implementation of the requested functionality in the future.