AUTHOR: Eyup Yusein
DATE POSTED: January 22, 2019
DESCRIPTION Usually you can keep various records in databases which can include letters and symbols from different cultures. Here are some of the diacritics of the Latin letter e for instance: éèëê.
For convenience to your users, you can choose to enable accent-insensitive filtering for the RadComboBox component.
SOLUTION
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
"server"
Filter
"Contains"
EmptyMessage
"Select a value"
>
Items
telerik:RadComboBoxItem
Text
"Luís"
Value
/>
"John"
John
"Luis"
"Doe"
Doe
"Lûis"
"Müller"
Müller
</
<script>
var
$ = $telerik.$, $T = Telerik.Web.UI, $I = $T.RadComboBoxItem;
Telerik.Web.UI.RadComboBoxItem.prototype._highlightOrg =
Telerik.Web.UI.RadComboBoxItem.prototype._highlight;
Telerik.Web.UI.RadComboBoxItem.prototype._highlight =
function
(regex, element) {
text = $(element).text().trim();
$(element).text(replaceDiacritics(text));
//$(element).text(text.normalize('NFD').replace(/[\u0300-\u036f]/g, "")); - not supported in IE
matchIsFound =
this
._highlightOrg(regex, element);
highlightedText = $(element).html().trim();
highlightStartPosition = highlightedText.indexOf(
"<em>"
);
text = [text.slice(0, highlightStartPosition),
, text.slice(highlightStartPosition)].join(
''
highlightEndPosition = highlightedText.indexOf(
"</em>"
text = [text.slice(0, highlightEndPosition),
, text.slice(highlightEndPosition)].join(
$(element).html(text);
return
matchIsFound;
}
Telerik.Web.UI.RadComboBoxItem.prototype.highlightText =
(filter, text) {
.clearEmTags();
if
(text ===
""
)
true
;
escapedText = $I._regExEscape(replaceDiacritics(text)),
regex =
null
(filter == $T.RadComboBoxFilter.StartsWith)
new
RegExp(
"^\\s*"
+ escapedText,
"im"
else
(filter == $T.RadComboBoxFilter.Contains)
RegExp(escapedText,
"gim"
._highlight(regex,
.get_element());
replaceDiacritics(str) {
diacritics = [
{ char:
'A'
, base: /[\300-\306]/g },
'a'
, base: /[\340-\346]/g },
'E'
, base: /[\310-\313]/g },
'e'
, base: /[\350-\353]/g },
'I'
, base: /[\314-\317]/g },
'i'
, base: /[\354-\357]/g },
'O'
, base: /[\322-\330]/g },
'o'
, base: /[\362-\370]/g },
'U'
, base: /[\331-\334]/g },
'u'
, base: /[\371-\374]/g },
'N'
, base: /[\321]/g },
'n'
, base: /[\361]/g },
'C'
, base: /[\307]/g },
'c'
, base: /[\347]/g }
]
diacritics.forEach(
(letter) {
str = str.replace(letter.base, letter.char);
});
str;
};
</script>
Resources Buy Try