[英]Kendo Grid (Angular 2+) Can't filter number Column
使用Kendo Plunker鏈接中的官方網格過濾示例,如果我為ProductID字段啟用了過濾器,則該過濾器不起作用,並且在控制台中看到以下錯誤。 基本上,所有編號的列過濾器均不起作用。 但是,如果數據類型為字符串,則可以使用。
錯誤:
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)
如果d.ProductID
既不為null
, undefined
也不為string
類型,則拋出錯誤,例如d.ProductID = 12
。 我在您的示例中假設id是數字類型。
我對這個庫不熟悉,但是如果您看一下示例,它們確實有一個數值過濾器:
<kendo-grid-column field="UnitPrice" title="Unit Price" width="180" filter="numeric" format="{0:c}">
id應該表示為字符串,而不是整數。 根據經驗,只有在算術運算有意義的情況下,才應使用整數。 例如,如果您可以添加兩個實例。 ID是名稱,即使它們由數字表示也是如此。 (就像電話號碼一樣)。 因此,您應該在此處使用字符串表示形式。
Kendo網格過濾使用字符串作為默認值。 您需要在過濾器中指定值的類型。 即:filter =“ date”,filter =“ numeric”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.