Hello, I'm using Kendo.Mvc and Kendo.UI for developing an ASP.NET MVC web application.
I have a Grid with ajax binding that reads data from a Datatable, those data could be of different types (string, int, double, bool, ecc..).
I have no model strongly typed associated for this Grid, thus I'll check for the type of each column and I do the bind for each column based of their type.
My problem is that this binding seems not to be working, because each column filter is treated as if it were of type string.
here some code snippet:
initialization: Html.Kendo().Grid<
object
>()
// other code
for
each column:
grid.Columns(columns =>
{
var bound = columns.Bound(Type.GetType(
"System."
+ col.Type), col.Name);
// other code
bound.Filterable(
true
);
})
where col.Type
is
an
enum
similar to .NET TypeCode Enumeration (https:
//msdn.microsoft.com/en-us/library/system.typecode(v=vs.110).aspx)
I've also tried to add manually the type of column, after initialization of the grid, with some client side javascript code:
$.each(cols,
function
(i, e) {
var
index = grid.columns.map(
function
(obj) {
return
obj.field;
})
.indexOf(e.Name);
if
(index > -1) {
var
item = grid.columns[index];
switch
(e.Type) {
case
"string"
:
item.type = e.Type;
break
;
case
"double"
:
case
"integer"
:
item.type =
"number"
;
break
;
case
"boolean"
:
item.type = e.Type;
break
;
case
"datetime"
:
item.type =
"date"
;
break
;
}
}
});
after doing this, I have a new "type" property for each column inside grid.columns but seems to not affect each column filter.
Some suggestion to achieve this?
Thanks a lot!