PDA

View Full Version : [CLOSED] ext.net combobox filter problem with Turkish characters



metci
Aug 31, 2015, 3:29 PM
Hi,

When user wants to filter data in an editable combobox that contains Turkish characters like 'İ' in values, filter does not work as user wants. When the user types 'i' as filter character, I think it's converted to 'I' character (because the value is in upper case) and if the value in combobox contains 'İ' character, no result is returned.

Is there any way to convert this 'i' character to 'İ' character as upper?

Regards.

Daniil
Sep 01, 2015, 11:25 PM
Hi @metci,

I don't think uppercasing happens there. The reason why typing "i" doesn't show items that contains "İ", because this returns false in JavaScript.

new RegExp("i", "i").test("İ")

I was able to come up with the following hack. Though, I am not sure it will work in all cases. Please test.

Example

<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.ComboBox1.GetStore();
store.DataSource = new object[]
{
new object[] { "1", "İ 1" },
new object[] { "2", "i two" },
new object[] { "3", "İ three" },
new object[] { "4", "Four" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var onBeforeQuery = function (queryPlan) {
queryPlan.query = new RegExp(queryPlan.query + "|" + queryPlan.query.replace("i", "İ"));
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:ComboBox
ID="ComboBox1"
runat="server"
DisplayField="text"
ValueField="value"
QueryMode="Local">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="value" />
<ext:ModelField Name="text" />
</Fields>
</ext:Model>
</Model>
<Reader>
<ext:ArrayReader />
</Reader>
</ext:Store>
</Store>
<Listeners>
<BeforeQuery Fn="onBeforeQuery" />
</Listeners>
</ext:ComboBox>
</form>
</body>
</html>

metci
Sep 02, 2015, 7:13 AM
Seems working fine with the query below.

Thanks.



var onBeforeQuery = function (queryPlan) {
queryPlan.query = new RegExp(queryPlan.query + "|" + queryPlan.query.replace("i", "İ") + "|" + queryPlan.query.replace("İ", "i"));
};