This question is locked. New answers and comments are not allowed.
Is there a way to add extra html attributes via the GridBuilder without removing any attributes already added?
I have some common custom attributes I add to grids so I wrapped up the code into some extension methods like this:
public static GridBuilder<
T
> CustomFilterBehaviour<
T
>(this GridBuilder<
T
> gridBuilder, string message = null) where T : class
{
return gridBuilder.HtmlAttributes(new {my_customFilter = (message ?? "")});
}
public static GridBuilder<
T
> CustomRowCountBehaviour<
T
>(this GridBuilder<
T
> gridBuilder, string message = null) where T : class
{
return gridBuilder.HtmlAttributes(new {my_customRowCount = (message ?? "")});
}
my JS routines then pick up on grid elements with these decorators to implement the behaviour. The trouble is the HtmlAttributes call overwrites any attributes already set, so if I declare a grid like this:
@(Html.Telerik().Grid<
Typology
>()
.Name("gridTypologies")
// custom behaviours
.CustomFilterBehaviour()
.CustomRowCountBehaviour()
The call to .CustomRowCountBehaviour() overwrites the attribute set by the call to .CustomFilterBehaviour(), so the "my_customFilter" decorator is lost and not output!! What I really want to do inside the extension methods is add an extra Html attribute to anything that is already present.
Any suggestions? Thanks