dojox/grid/enhanced/plugins/Search.js

  • Provides:

    • dojox.grid.enhanced.plugins.Search
  • Requires:

    • dojox.grid.enhanced._Plugin in common
    • dojo.data.util.filter in common in project dojo
  • dojox.grid.enhanced.plugins.Search

    • type
      Function
    • chains:
      • dojox.grid.enhanced._Plugin: (prototype)
      • dojox.grid.enhanced._Plugin: (call)
    • summary
      Search the grid using wildcard string or Regular Expression.
    • parameters:
      • grid: (typeof )
      • args: (typeof )
    • source: [view]
        this.grid = grid;
        args = (args && dojo.isObject(args)) ? args : {};
        this._cacheSize = args.cacheSize || -1;
        grid.searchRow = dojo.hitch(this, "searchRow");
  • dojox.grid.enhanced.plugins.Search.name

    • type
      String
    • summary
      plugin name
  • dojox.grid.enhanced.plugins.Search.searchRow

    • type
      Function
    • parameters:
      • searchArgs: (typeof Object|RegExp|String)
      • onSearched: (typeof function(Integer, item))
    • source: [view]
        if(!dojo.isFunction(onSearched)){ return; }
        if(dojo.isString(searchArgs)){
         searchArgs = dojo.data.util.filter.patternToRegExp(searchArgs);
        }
        var isGlobal = false;
        if(searchArgs instanceof RegExp){
         isGlobal = true;
        }else if(dojo.isObject(searchArgs)){
         var isEmpty = true;
         for(var field in searchArgs){
          if(dojo.isString(searchArgs[field])){
           searchArgs[field] = dojo.data.util.filter.patternToRegExp(searchArgs[field]);
          }
          isEmpty = false;
         }
         if(isEmpty){ return; }
        }else{
         return;
        }
        this._search(searchArgs, 0, onSearched, isGlobal);
    • summary
  • dojox.grid.enhanced.plugins.Search._search

    • type
      Function
    • parameters:
      • searchArgs: (typeof Object|RegExp)
      • start: (typeof Integer)
      • onSearched: (typeof function(Integer, item))
      • isGlobal: (typeof Boolean)
    • source: [view]
        var _this = this,
         cnt = this._cacheSize,
         args = {
          "start": start,
          "onBegin": function(size){
           _this._storeSize = size;
          },
          "onComplete": function(items){
           if(!dojo.some(items, function(item, i){
            if(_this._checkRow(item, searchArgs, isGlobal)){
             onSearched(start + i, item);
             return true;
            }
            return false;
           })){
            if(cnt > 0 && start + cnt < _this._storeSize){
             _this._search(searchArgs, start + cnt, onSearched, isGlobal);
            }else{
             onSearched(-1, null);
            }
           }
          }
         };
        if(cnt > 0){
         args.count = cnt;
        }
        this.grid._storeLayerFetch(args);
    • summary
  • dojox.grid.enhanced.plugins.Search._checkRow

    • type
      Function
    • parameters:
      • item: (typeof store item)
      • searchArgs: (typeof Object|RegExp)
      • isGlobal: (typeof Boolean)
    • source: [view]
        var g = this.grid, s = g.store, i, field,
         cells = dojo.filter(g.layout.cells, function(cell){
          return !cell.hidden;
         });
        if(isGlobal){
         return dojo.some(cells, function(cell){
          try{
           if(cell.field){
            return String(s.getValue(item, cell.field)).search(searchArgs) >= 0;
           }
          }catch(e){
           console.log("Search._checkRow() error: ", e);
          }
          return false;
         });
        }else{
         for(field in searchArgs){
          if(searchArgs[field] instanceof RegExp){
           for(i = cells.length - 1; i >= 0; --i){
            if(cells[i].field == field){
             try{
              if(String(s.getValue(item, field)).search(searchArgs[field]) < 0){
               return false;
              }
              break;
             }catch(e){
              return false;
             }
            }
           }
           if(i < 0){ return false; }
          }
         }
         return true;
        }
    • summary
  • dojox.grid.enhanced.plugins.Search.grid

    • summary
  • dojox.grid.enhanced.plugins.Search._cacheSize

    • summary
  • dojox.grid.enhanced.plugins

    • type
      Object
    • summary
  • dojox.grid.enhanced

    • type
      Object
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary