【发布时间】:2015-03-31 18:16:35
【问题描述】:
我在项目中使用 Typescript 时遇到了 Kendo UI 问题。我有一个网格,它的过滤模式不适用于某些列类型,比如整数。我试图直接在列中添加类型,但它根本不起作用。 而且它也不过滤链接。
[编辑] 这是我创建网格的函数代码:
private _createInfoGridOptions(): kendo.ui.GridOptions {
return {
dataSource: {
serverPaging: true,
serverSorting: true,
pageSize: 15,
},
resizable: true,
selectable: 'row',
filterable: true,
columnMenu: true,
sortable: true,
scrollable: {
virtual: true
},
groupable: true,
height: 450,
columns: [
{ field: 'subTaskId', type: "number", title: 'Subtask Id', width: '80px' },
{ field: 'reportDate', type:"date", title: 'Report Date', width: '100px', template: '#= moment.utc(reportDate).local().format("yyyy/mm/dd") #' },
{ field: 'prog', type: "string", title: 'prog', width: '60px', template: "<a href='\\#' ng-click=\"openpopup(#=prog#, \'#=reportDate#\'\')\">#=prog#</a>" },
{ field: 'state', type:"string", title: 'status', width: '130px' },
{ field: 'maxTemps', type: 'number', title: 'Max Temps', width: '100px' }
]
};
}
我在 Chrome 上遇到此错误:
未捕获的 TypeError: (d.prog || "").toLowerCase 不是函数
还有这个在 Firefox 上:
TypeError: "".toLowerCase 不是函数。
我做了一个plunker 来测试我用 javascript 翻译的代码,但 type 属性有效。
$("#grid").kendoGrid({
dataSource:
{
data : [
{id: 36308,reportDate:"2015-02-01",prog: 58,state: "Waiting",maxTemps: 0},
{id: 36309,reportDate:"2015-02-01",prog: 34,state: "Complete",maxTemps: 86400},
{id: 36310,reportDate:"2015-02-01",prog: 116,state: "Complete",maxTemps: 86400},
{id: 36311,reportDate:"2015-02-02",prog: 58,state: "Complete",maxTemps: 86400}
],
serverPaging: true,
serverSorting: true,
pageSize: 15
},
filterable: true,
columnMenu: true,
columns: [
{ field: 'id', type:'number', title: 'Id', width: '80px' },
{ field: 'reportDate', title: 'Report Date', width: '100px' },
{ field: 'prog', type:'number', title: 'Prog', width: '60px' },
{ field: 'state', title: 'Status', width: '130px' },
{ field: 'maxTemps', type:'number', title: 'Max Temps', width: '100px' }
]
});
所以它可以在 Javascript 中工作,但不能在 Typescript 中工作,我正在使用带有 Kendo UI 的 AngularJS。 任何想法为什么它不醒来?
谢谢!
金乌
【问题讨论】:
-
你添加定义了吗?
-
定义?如果您在谈论 DefinetelyTyped 脚本,是的,我将它们添加到我的项目中。
-
datasource里面生成的数据是从哪里来的?你没有提到任何
readURL -
对不起,我在Javascript Plunker中放了一个例子,数据是从另一个函数收费的。 div 看起来像这样:
<div id="resultSubTasksGrid" kendo-grid="resultGrid" class="table table-striped table-hover" k-options="infoGridOptions" k-data-source="source"></div>数据来自对象源。
标签: javascript angularjs kendo-ui typescript kendo-grid