2017-08-03 48 views
0

使用來自Kendo的官方網格過濾示例Plunker link,如果我爲產品ID字段啓用過濾器,那麼過濾器不起作用,並在控制檯中看到以下錯誤。基本上,編號欄過濾器都沒有工作。但是,如果數據類型是字符串,它的工作。Kendo Grid(Angular 2+)無法過濾編號列

ERROR:

ERROR TypeError: (d.ProductID || "").toLowerCase is not a function 
    at eval (eval at t.compileFilter (VM1859 kendo-data-query.js:NaN), <anonymous>:3:29) 
    at Object.t.count (VM1859 kendo-data-query.js:1) 
    at Object.t.process (VM1859 kendo-data-query.js:1) 
    at AppComponent.dataStateChange (VM1970 app.component.ts!transpiled:22) 
    at Object.eval [as handleEvent] (VM1971 AppComponent.ngfactory.js:23) 
    at handleEvent (VM856 core.umd.js:12108) 
    at callWithDebugContext (VM856 core.umd.js:13567) 
    at Object.debugHandleEvent [as handleEvent] (VM856 core.umd.js:13155) 
    at dispatchEvent (VM856 core.umd.js:8720) 
    at eval (VM856 core.umd.js:10882) 
+0

目前我通過將數據類型轉換爲字符串來做了一個解決方法。但是這個bug需要由Kendo團隊解決。 – ZabedAkbar

回答

1

這引發錯誤,如果d.ProductID既不nullundefined也不string的類型,例如如果d.ProductID = 12。我假設你的例子中的id是類型號碼。

我不熟悉這個庫,但如果你看一下例子,他們確實有數值的過濾器:

<kendo-grid-column field="UnitPrice" title="Unit Price" width="180" filter="numeric" format="{0:c}"> 

一個ID應該被表示爲一個字符串,雖然不是一個整數。作爲一個經驗法則,只有在算術運算有意義時才應使用整數;例如如果你可以添加兩個實例。即使它們是由數字表示,ID也是名稱。 (就像電話號碼)。因此,你應該在這裏使用一個字符串表示。