我有一个简单的类来包装一个网格控件,我将它放在一个名为 Components 的模块中,当我在 Firefox 14.0.1 中测试它时,我得到:
TypeError: Components.Grid 不是构造函数@http://...
这里是 TypeScript 生成的代码:
var Components;
(function (Components) {
Components.gridDefaults = {
datatype: "json",
autowidth: true,
rowNum: 30,
rowList: [
10,
20,
30
],
viewrecords: true,
sortorder: "asc",
pager: "#grid-pager"
};
var Grid = (function () {
function Grid(selector, options) {
var opts = Components.gridDefaults;
if(options !== undefined && options !== null) {
$.extend(opts, options);
}
this.grid = $(selector).jqGrid(opts);
}
Grid.prototype.setToolbar = function (options) {
var pager = this.grid.getGridParam().pager;
if(pager !== undefined && pager !== null) {
this.grid.navGrid(pager, options);
}
return this;
};
Grid.prototype.jqGrid = function () {
return this.grid;
};
Grid.prototype.filter = function (criteria) {
this.grid.setGridParam({
page: 1,
postData: criteria
});
this.reload();
};
Grid.prototype.reload = function () {
this.grid.trigger("reloadGrid");
};
return Grid;
})();
Components.Grid = Grid;
})(Components || (Components = {}));
//@ sourceMappingURL=grid-component.js.map
在这里,Firefox 抱怨缺少构造函数:
var grid = new Components.Grid("#grid-container", {
url: "/Home/Data",
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [
{ name: 'id', index: 'id', width: 55 },
{ name: 'invdate', index: 'invdate', width: 90, jsonmap: "invdate" },
{ name: 'name', index: 'name asc, invdate', width: 100 },
{ name: 'amount', index: 'amount', width: 80, align: "right" },
{ name: 'tax', index: 'tax', width: 80, align: "right" },
{ name: 'total', index: 'total', width: 80, align: "right" },
{ name: 'note', index: 'note', width: 150, sortable: false }
],
jsonReader: {
id: "id",
repeatitems: false
}
});
我想听听@TypeScript 团队的消息。