.net - kendo ui grid filter case insensitive -
i'm trying enable case insensitive filtering (server side) kendo grid. know way inject tolower (toupper, etc) filter enable case insensitive filtering?
background:
i dropped kendo grid in consume data controller (entitysetcontroller
, .net 4.5) , seems work well. inline editing, server paging, adding new rows, etc.
to enable case insensitive filtering knockout, build filter filter text , field wrapped in tolower (as recommended here). haven't found way customize filter using kendo elements.
controller:
public class categoriescontroller : entitysetcontroller<category, int> { public override iqueryable<category> get() { return _repository.find().orderby(c => c.name); } }
data source creation:
var servicebaseurl = "api/categories", datasource = new kendo.data.datasource({ type: "odata", transport: { read: { url: servicebaseurl, datatype: "json" } }, schema: { // omitted brevity }, serverfiltering: true, serverpaging: true, pagesize: 10 });
grid creation:
$("#grid").kendogrid({ datasource: datasource, pageable: true, filterable: { extra: false, operators: { string: { contains: "contains", } } }, columns: [ // omitted brevity ] });
based on total lack of response, i'm guessing few other people ran issue , didn't see obvious solution came with. in case other poor soul stuck was, here came with.
the transport object on data source needs function called parametermap. in that, following:
parametermap: function (data, type) { if (type == "read") { if (namefilter) { // pull namefilter viewmodel or wherever data.filter = { field: "tolower(name)", operator: "contains", value: namefilter.tolowercase() }; } var newdata = kendo.data.transports.odata.parametermap(data); delete newdata.$format; // not supported webapi. return newdata; } },
i did simplifying purposes of answer, apologies if example broken. did best make functional.
Comments
Post a Comment