2013-05-05 62 views
0

我想要在我的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

一切看起來有效的與您的代碼。確保您有可用的服務。 Here是與您的代碼jsbin,只有在運輸方面有所不同:

function cityFilter(element) { 
    element.kendoDropDownList({ 
    dataSource: { 
     severFiltering: true, 
     transport: { 
      read: { 
      dataType: "jsonp", 
      url: "http://demos.kendoui.com/service/Products" 
      } 
     }, 
     }, 
    dataTextField:"ProductName", 
    optionLabel: "--Select Value--" 
    }); 
} 
+0

我明白了。我這樣做.. 功能cityFilter(元素){ element.kendoDropDownList({ 數據源:{ 運輸:{ 讀: 「HTTP://本地主機:8888/City.php」 }, 模式:{ data:「data」 }}, serverFiltering:true, dataTextField:「State_Long」, optionLabel:「--Select Value--」 }); } – 2013-05-05 18:09:00

相關問題