2017-01-06 7 views
0

Kendo DropDownListの組み込み検索で、dataSourceの生のテキストの代わりにテンプレートのテキストを使用することができません。私は、表示、値、および検索の目的で、dataSource名から先行するスラッシュを取り除きたい。ここでKendo DropDownListテンプレートの変更されたテキストの検索

<script> 
$("#dropdownlist").kendoDropDownList({ 
    dataSource: [ "/Apples", "/Oranges" ], 

    // None of these templates appear to fix the search text. 
    // Kendo is using the dataSource item to search instead of the template output. 
    // I want to be able to search using 'a' (for Apples) or 'o' (for Oranges). 
    // If I use '/' then it cycles through the items which proves to me that the search is not using templated text. 

    template: function(t) { return t.name.slice(1); }, 
    valueTemplate: function(t) { return t.name.slice(1); }, 
    optionLabelTemplate : function (t) { return t.name.slice(1); }, 

}); 
</script> 

は剣道のUIテスターで非稼働サンプルです:

http://dojo.telerik.com/@Jeremy/UvOFo

私は簡単にサーバー側でデータソースを変更することはできません。

検索の仕組みを変更できない場合は、サーバーからクライアントに読み込まれた後にdataSourceを変更する方法がありますか?

答えて

0

これがまったく役に立たないかどうかわかりませんが、強制的に動作させることができました。このコントロールを使用すると、initのフィルタリングイベントを購読することができます。ここから、フィルタを提出する前にその値を設定できます。

<script> 
$("#dropdownlist").kendoDropDownList({ 
    dataSource: ["/Apples", "/Oranges"], 
    template: function(t) { return t.slice(1); }, 
    valueTemplate: function(t) { return t.slice(1); }, 
    optionLabelTemplate : function (t) { return t.slice(0); }, 
    filter: "startswith", 
    filtering: function(e) { 
     e.filter.value = '/'+e.filter.value; 
    } 
}); 
</script> 
+0

THX - ドロップダウンを開いて_filter_入力ボックスに入力すると、ソリューションが動作します。私は私の質問で十分に明確ではなかった。 Kendo DropDownListには、2種類のフィルタ/検索機能が必要です。 1つは入力ボックス用、もう1つはキー入力用です。私は集中しているが開かれていないDropDownListで動作するようにキー押下検索をしようとしていました。 'filter'属性が定義されると、 'a'、 'o'、 '/'のどちらを入力しても、キーの押下は全く機能しません。あなたの答えはおおよそ質問と一致しますので、私はあなたに信用を与えます。 keypressではなく入力ボックスを使用するようにUIを切り替えます。 – Jeremy

関連する問題