禁用dojo datagrid上的异常捕获
当DataGrid呈现时,如果它在呈现过程中遇到错误(在我的例子中,通常是cell.formatter或cell.get),网格会捕获异常,中止整个过程,并简单地显示模糊的消息“抱歉,发生了错误”禁用dojo datagrid上的异常捕获,dojo,dojox.grid.datagrid,Dojo,Dojox.grid.datagrid,当DataGrid呈现时,如果它在呈现过程中遇到错误(在我的例子中,通常是cell.formatter或cell.get),网格会捕获异常,中止整个过程,并简单地显示模糊的消息“抱歉,发生了错误” 有没有一种方法可以抑制异常捕获,以便在发生错误时,它会出现在调试控制台中?我没有找到使用dojo的默认行为来实现这一点的方法,因此作为一种解决方法,我在将布局结构传递到网格之前,制作了一个小实用程序来更改布局结构。(有点像黑客,但是我用脚本制作了网格,没有标记,所以现在它可以工作了,而且一个新的网格已
有没有一种方法可以抑制异常捕获,以便在发生错误时,它会出现在调试控制台中?我没有找到使用dojo的默认行为来实现这一点的方法,因此作为一种解决方法,我在将布局结构传递到网格之前,制作了一个小实用程序来更改布局结构。(有点像黑客,但是我用脚本制作了网格,没有标记,所以现在它可以工作了,而且一个新的网格已经在绘图板上了
lib.wrapTryCatch = function(call, onException){
onException = onException || function(e){
console.log({wrappedException: e});
return e.message;
};
var f = function tryWrapper(){
try{
var val = call.apply(this, arguments);
return val;
}
catch(e){
return onException(e);
}
}
f.wrapped = call;
f.onException = onException;
return f;
}
lib.gridUtils = {
/** Convenience/debugging function to make exceptions visible
* if grid structure cells have errors.
*
* Puts exception to the console, instead of the grid's default
* behavior of dying silently
*
* */
decorateStructure: function(structure){
for(var idx in structure){
cell = structure[idx];
if('get' in cell){
cell.get = lib.wrapTryCatch(cell.get);
}
if('formatter' in cell){
cell.formatter = lib.wrapTryCatch(cell.formatter);
}
}
return structure;
}
}