我有一个增强的网格并激活了“打印机”插件。此外,我制作了一个 dijit/button 并将其连接到一个 onClick 事件,该事件调用一个打印方法。该事件被触发,所以没有问题。问题是,它不起作用。我在 Opera 控制台中收到以下消息:
Uncaught exception: TypeError: Cannot convert 'str' to object
Error thrown at line 511, column 21 in <anonymous function: trim>(str) in http://localhost/ci/assets/js/dojo/_base/lang.js:
return str.trim();
called from line 131, column 3 in <anonymous function: _loadCSSFiles>(cssFile) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
cssFile = lang.trim(cssFile);
called from line 282, column 5 in <anonymous function: map>(arr, callback, thisObject, Ctr) in http://localhost/ci/assets/js/dojo/_base/array.js:
out[i] = callback(arr[i], i, arr);
called from line 130, column 2 in <anonymous function: _loadCSSFiles>(cssFiles) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
var dl = array.map(cssFiles, function(cssFile){
called from line 226, column 2 in <anonymous function: _wrapHTML>(title, cssFiles, body_content) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
return this._loadCSSFiles(cssFiles).then(function(cssStrs){
called from line 125, column 3 in <anonymous function: exportSelectedToHTML>(str) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
_this._wrapHTML(args.title, args.cssFiles, args.titleInBody + str).then(onExported);
called from line 128, column 2 in <anonymous function: exportSelected>(type, writerArgs, onExported) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Exporter.js:
return onExported(this._goThroughGridData(this.grid.selection.getSelected(), writer));
called via Function.prototype.apply() from line 375, column 68 in <anonymous function: hitch>() in http://localhost/ci/assets/js/dojo/_base/lang.js:
return method.apply(scope, arguments || []);
called from line 124, column 2 in <anonymous function: exportSelectedToHTML>(args, onExported) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
this.grid.exportSelected("table", args.writerArgs, function(str){
called from line 94, column 2 in <anonymous function: printSelected>(args) in http://localhost/ci/assets/js/dojox/grid/enhanced/plugins/Printer.js:
this.exportSelectedToHTML(args, lang.hitch(this, this._print));
这是事件的代码:
require([
"dijit/registry"
],function(registry) {
var grid = registry.byId('grid');
grid.printSelected({
"title": "test"
});
});
有人知道我能做什么来让这个插件工作吗?
PS:我也试过用谷歌浏览器打印,但这都不行……