The implementation of GridBuilder<T>.TableHtmlAttributes() suggests that you should be able to call it multiple times and have the results merged:
However, when I try to call TableHtmlAttributes more than once on the same grid, the attributes added by the first call are removed by the second, even though the names do not conflict:
How can I prevent this behavior?
We have several attribute-based custom functions that we have built on top of Kendo grids, and I would like to create optional extension methods for the MVC builder to add these in the grid definition, like this:
The above approach is not possible if each call overwrites the previous ones.
public GridBuilder<T> TableHtmlAttributes(IDictionary<string, object> attributes){ this.Component.TableHtmlAttributes.Clear(); Kendo.Mvc.Extensions.DictionaryExtensions.Merge(this.Component.TableHtmlAttributes, attributes); return this;}However, when I try to call TableHtmlAttributes more than once on the same grid, the attributes added by the first call are removed by the second, even though the names do not conflict:
.TableHtmlAttributes(new KeyValuePair<string, object>("k-grid-tab-new-row", null).ToDictionary()).TableHtmlAttributes(new KeyValuePair<string, object>("class", "custom-table-hover table table-bordered no-footer k-grid-single-line ").ToDictionary())How can I prevent this behavior?
We have several attribute-based custom functions that we have built on top of Kendo grids, and I would like to create optional extension methods for the MVC builder to add these in the grid definition, like this:
public static GridBuilder<T> TabNewRow<T>(this GridBuilder<T> builder)where T : class{ return builder.TableHtmlAttributes(new KeyValuePair<string, object>("k-grid-tab-new-row", null).ToDictionary());}The above approach is not possible if each call overwrites the previous ones.
