4 Answers, 1 is accepted
0
Hi Matthias,
In general you can create custom fields in the dataSource that you can access via the dataItem, however they are not directly related to the data attributes of the element, and this cannot be achieved out of the box. But as I am not really sure that I understand your question correctly, would it be possible to elaborate a bit more on this matter?
Regards,
Kiril Nikolov
Telerik
In general you can create custom fields in the dataSource that you can access via the dataItem, however they are not directly related to the data attributes of the element, and this cannot be achieved out of the box. But as I am not really sure that I understand your question correctly, would it be possible to elaborate a bit more on this matter?
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bruce
Top achievements
Rank 1
answered on 10 Jul 2019, 09:21 PM
I had the same question tonight and came across this post. So even though its a really old post, I'm going to answer it.
You have to specify data_ instead of data- as part of the HtmlAttributes collection.
So for example:
Html.Kendo().Button().Name(
"btnProgressLeadValidation"
)
.Content(
"Promote to Lead"
)
.HtmlAttributes(
new
{ type =
"button"
, @
class
=
"k-primary progress-button"
, data_label =
"Lead Validation"
})
.Events(events => events.Click(
"onProgressClick"
))
.Render();
Note the data_lead bit in the HtmlAttributes
That will render at the below Html:
<
button
class
=
"k-primary progress-button"
data-label
=
"Lead Validation"
id
=
"btnProgressLeadValidation"
type
=
"button"
>Promote to Lead</
button
>
Hope this helps someone.
0
Hi Bruce,
Thank you for sharing this solution with the community.
Best regards,
Dimitar
Progress Telerik
Thank you for sharing this solution with the community.
Best regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jason
Top achievements
Rank 1
answered on 08 Oct 2020, 01:06 PM
This helped so much. I needed the data attribute and it wasnt clear how to add.