I have the following code to create a Kendo Grid inside my custom HtmlHelper. The Ajax will return a 3 column data set to the DataSource (ID, Number, Name). No matter what I do, the Grid will return all the columns, and even if I try to change the title of the Number column to "Test Column" it has no effect. What am I missing?
public static IHtmlContent FilterGrid<T>(this IHtmlHelper<T> html, string Name, string Controller) where T : class
{
HtmlContentBuilder htmlBuilder = new HtmlContentBuilder();
htmlBuilder.AppendHtml(html.Kendo().DataSource<T>()
.Name("ds_" + Name)
.Ajax(dataSource => dataSource
.PageSize(20)
.Read(read => read.Action(Name + "_Read", Controller))
)
);
htmlBuilder.AppendHtml(html.Kendo().Grid<T>()
.Name("g_" + Name)
.Pageable()
.Sortable()
.NoRecords()
.DataSource("ds_" + Name)
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
.Columns(c => {
c.Bound("Number").Title("Test title");
})
);
return htmlBuilder;
}
Turns out it was caused by the persisting of the state of the grid in local storage.