Please read from here: http://stackoverflow.com/questions/36495655/get-column-name-from-container-or-create-generic-function-for-any-column
(There is also a support ticket open, so no admin has to sweat over here if they don't want to).
Because I'm using a lot of kendo grids spread in the whole web app, I start to introduce some redundant code that causes me a lot of troubles. Imagine to have something like:
//MVC:...
columns.Bound(c => c.Column1).Filterable(f => f.Extra(false).Operators(o => o.ForString(str => str.Clear().Contains("Contains"))).Cell(c => .ShowOperators(false).Template("column1Filter"))).Title("Column One");
...
//JS:
function column1Filter(container) {
container.element.kendoAutoComplete({
filter: "contains",
dataTextField: "Column1",
dataValueField: "Column1",
valuePrimitive: true,
dataSource: container.dataSource
});
}
Then, having this method reproduced for each single columns in each single grids. Is there any way where I can I have only one method that creates the kendo autocomplete?
E.G:
function genericAutocompleteFilter(container) {
var columnsName = //...Meh!
container.element.kendoAutoComplete({ filter: "contains", dataTextField: columnsName, dataValueField: columnsName, valuePrimitive: true, dataSource: container.dataSource });
}