kendo在数字字段上自动完成 [英] kendo autocomplete on numeric field
本文介绍了kendo在数字字段上自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试使用自动完成功能,但是我的dataTextField是一个整数.所以我不断收到"tolower"或"indexof"错误.不能找到一个人试图用数字自动完成的例子.
Trying to use autocomplete but my dataTextField is an integer. So I keep getting "tolower" or "indexof" error. Cant find a single example of someone trying to autocomplete with numbers.
PS:与文本字段配合使用
PS: works fine with a text field
$("#autocomplete").kendoAutoComplete({
dataTextField: "value",
select: function(e) {
var dataItem = this.dataItem(e.item.index());
//output selected dataItem
$("#result").html(kendo.dataItem);
},
dataSource: {
data: [
{ id : 1, value: 1 },
{ id : 2, value: 2 },
{ id : 3, value: 3 },
{ id : 4, value: 4 }
]
}
});
推荐答案
作为解决方法,您可以尝试将toLowerCase()
原型添加到Number
As a workaround, you can try adding the toLowerCase()
prototype to Number
$(document).ready(function() {
if (!Number.prototype.toLowerCase) {
Number.prototype.toLowerCase = function() {
return this.toString();
}
}
});
$(document).ready(function() {
if (!Number.prototype.toLowerCase) {
Number.prototype.toLowerCase = function() {
return this.toString();
}
}
});
$("#autocomplete").kendoAutoComplete({
dataTextField: "value",
select: function(e) {
var dataItem = this.dataItem(e.item.index());
//output selected dataItem
$("#result").html(kendo.dataItem);
},
dataSource: {
data: [{
id: 1,
value: 1
}, {
id: 2,
value: 2
}, {
id: 3,
value: 3
}, {
id: 4,
value: 4
}]
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.common.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<input id="autocomplete" />
<div id="result"></div>
这篇关于kendo在数字字段上自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文