我正在尝试在我的Kendo网格中使用自定义菜单过滤器。使用此代码,菜单永远不会加载,只是一直有旋转的圆圈。我使用的是最新版本的kendo。我做错了什么?
{
field: "City",
title: "City",
width: 110,
filterable: {
ui: cityFilter
}
}
function cityFilter(element) {
element.kendoDropDownList({
dataSource: {
type: "odata",
severFiltering: true,
transport: {
read: "http://localhost:8888/City.php"
}
},
optionLabel: "--Select Value--"
});
}
PHP:
<?php
$link = mysql_pconnect("127.0.0.1", "root", "admin") or die("Unable To Connect To Database Server");
mysql_select_db("MainDatabase") or die("Unable To Connect To Northwind");
$arr = array();
$rs = mysql_query("SELECT State_Long FROM MainDatabase.Stations Group by State_Long");
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
// add the header line to specify that the content type is JSON
header("Content-type: application/json");
echo "{\"data\":" .json_encode($arr). "}";
?>
答案 0 :(得分:0)
所有内容对您的代码都有效。确保您有可用的服务。 Here是jsbin,您的代码仅在传输中有所不同:
e.g。
function cityFilter(element) {
element.kendoDropDownList({
dataSource: {
severFiltering: true,
transport: {
read: {
dataType: "jsonp",
url: "http://demos.kendoui.com/service/Products"
}
},
},
dataTextField:"ProductName",
optionLabel: "--Select Value--"
});
}