asp.net - Accent insensitive searching in RadComboBox -
i'm relatively new using asp webforms , telerik, i'm looking way allows me type special characters (é, ù, à, ...) in radcombobox
.
lets have name in objectdatasource
called "rené somebody". need able find him searching "rene" , "rené", far no luck.
in application managed on radgrid
filters, same solution doesn't work radcombobox
far know.
the solution used in radgrid
: http://www.telerik.com/forums/accent-insensitive-filtering-filtering-on-a-different-column#ys1qt8p1u0-crpfnfjvdza
i have no access backend components demo linked contains frontend code , looks can hack in there. looks control may both client-server , client-side only. client-side hacks looks kind of complicated , invloves non-public api (_oninputchange
) client-server case (which case) doc on client side of radcombobox object mentions requestitems
method hacking reasonably future safe:
var hackradcomboboxfilter = function (combobox, filterprocessingfunction) { var oldrequestitems = combobox.requestitems; combobox.requestitems = function() { var args = array.prototype.slice.call(arguments); // requestitems has several arguments text seems // first one, let's modify , call original method var origfilter = args[0]; args[0] = filterprocessingfunction(origfilter); oldrequestitems.apply(this, args); } };
unfortunately don't know built-in way deal accents in js can hack simple here well:
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; var mappedaccents = "aaaaaaaaaaaaoooooooooooooeeeeeeeeeccdiiiiiiiiuuuuuuuunnssyyyzz"; var removeaccents = function (origstr) { var components = []; var len = origstr.length; var afterlastaccent = 0; (var = 0; < len; i++) { var mappos = accents.indexof(origstr[i]); if (mappos != -1) { components.push(origstr.substr(afterlastaccent, - afterlastaccent) + mappedaccents[mappos]); afterlastaccent = + 1; } } if (afterlastaccent < len) components.push(origstr.substr(afterlastaccent, len - afterlastaccent)); return components.join(''); };
so can combine in this:
// in real app want // var targetcombobox = $find("<%= radcombobox1.clientid %>"); // test let's hack first combobox on page var targetcombobox = telerik.web.ui.radcombobox.comboboxes[0]; hackradcomboboxfilter(targetcombobox, removeaccents);
or if want modify comboboxes on page, can change prototype using same trick:
hackradcomboboxfilter(telerik.web.ui.radcombobox.prototype, removeaccents)
Comments
Post a Comment