当前位置: 代码迷 >> Web前端 >> 把函数作为参数传面交函数,实现查找功能
  详细解决方案

把函数作为参数传面交函数,实现查找功能

热度:250   发布时间:2012-09-17 12:06:51.0
把函数作为参数传递给函数,实现查找功能

?/**
?????? * get the cell by the id of the? widget that column bounded.
?????? * @param wid the id of the bounded widget.
?????? */
????? me.getCellById = function (wid){
??? ??? ? var okCell;
??? ??? ? me.foreachCell(function (cell){
??? ??? ??? ?? if(cell.cellWidget && cell.cellWidget.id==wid){
??? ??? ??? ??? ?? okCell = cell;
??? ??? ??? ?? }
??? ??? ? });
??? ??? ? return okCell;
????? };
?????
????? me.foreachCell = function(fn){
??? ??? ??? var cells = me.getAllCells();
??????????? for(var n = 0,len = cells.length;n<len;n++){
??? ??? ??? ??? (fn)(cells[n]);
??? ??? ??? }
??? ? };

  相关解决方案