This is a migrated thread and some comments may be shown as answers.

[Solved] HtmlAttributes on a row

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sébastien
Top achievements
Rank 1
Sébastien asked on 30 Nov 2011, 09:30 AM
Hi guys,
I would like to add some html attributes on a row grid, i'm using AJAX databinding.
I found a HtmlAttributes and a TableHtmlAttributes method but not a "RowHtmlAttributes"...
I can't using the RowAction because i'm not using server binding....

Moreover, is it possible that an htmlattribute comes from my datasource (my JSON result returns a "action" node with a value, I would like to add this value on a personnal HTML5 attribute on my row, like data-action).

Thanks !

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Dec 2011, 09:01 AM
Hello Sébastien,


You could use the OnRowDataBound client side event to add the attribute. For example, if your Model(datasource) contains a property with name "Action" and you want to set its value to a "data-action" attribute, you could use the OnRowDataBound handler in the snippet below to do it:

function onRowDataBound(e) {
        $(e.row).attr('data-action', e.dataItem.Action);
    }



Best wishes,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sébastien
Top achievements
Rank 1
answered on 01 Dec 2011, 09:22 AM
Yes, it's exactly what I did in fact :) !

Thanks !
Tags
Grid
Asked by
Sébastien
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Sébastien
Top achievements
Rank 1
Share this question
or