dojox/grid/enhanced/plugins/_StoreLayer.js

  • Provides:

    • dojox.grid.enhanced.plugins._StoreLayer
  • dojox.grid.enhanced.plugins._StoreLayer

    • type
      Function
    • summary
      The most abstract class of store layers, provides basic utilities and some interfaces.
    • source: [view]
         this._store = null;
         this._originFetch = null;
         this.__enabled = true;
  • dojox.grid.enhanced.plugins._StoreLayer._store

    • tags: protected
    • type
      Read-store
    • summary
      The wrapped store.
  • dojox.grid.enhanced.plugins._StoreLayer._originFetch

    • tags: protected
    • type
      function
    • summary
      The original fetch function of the store.
  • dojox.grid.enhanced.plugins._StoreLayer.__enabled

    • tags: private
    • type
      Boolean
    • summary
      To control whether this layer is valid.
  • dojox.grid.enhanced.plugins._StoreLayer.tags

    • type
      abstract
    • summary
  • dojox.grid.enhanced.plugins._StoreLayer.layerFuncName

    • summary
  • dojox.grid.enhanced.plugins._StoreLayer.initialize

    • type
      Function
    • parameters:
      • store: (typeof )
    • source: [view]
         // summary:
         //
    • summary
  • dojox.grid.enhanced.plugins._StoreLayer.uninitialize

    • type
      Function
    • parameters:
      • store: (typeof )
    • source: [view]
         // summary:
         //
    • summary
  • dojox.grid.enhanced.plugins._StoreLayer.invalidate

    • type
      Function
    • source: [view]
    • summary
  • dojox.grid.enhanced.plugins._StoreLayer._wrap

    • type
      Function
    • parameters:
      • store: (typeof Read-store)
        The store to be wrapped.
      • funcName: (typeof )
      • layerFuncName: (typeof )
      • nextLayer: (typeof )
    • source: [view]
         this._store = store;
         this._funcName = funcName;
         var fetchFunc = dojo.hitch(this, function(){
          return (this.enabled() ? this[layerFuncName || this.layerFuncName] : this.originFetch).apply(this, arguments);
         });
         if(nextLayer){
          this._originFetch = nextLayer._originFetch;
          nextLayer._originFetch = fetchFunc;
         }else{
          this._originFetch = store[funcName] || function(){};
          store[funcName] = fetchFunc;
         }
         this.initialize(store);
    • summary
      Do the actual wrapping (or 'hacking' if you like) to the store.
    • tags:
  • dojox.grid.enhanced.plugins._StoreLayer._unwrap

    • type
      Function
    • parameters:
      • nextLayer: (typeof )
    • source: [view]
         this.uninitialize(this._store);
         if(nextLayer){
          nextLayer._originFetch = this._originFetch;
         }else{
          this._store[this._funcName] = this._originFetch;
         }
         this._originFetch = null;
         this._store = null;
    • summary
      Do the actual unwrapping to the store.
    • tags:
  • dojox.grid.enhanced.plugins._StoreLayer.enabled

    • type
      Function
    • parameters:
      • toEnable: (typeof bool)
        Boolean?
        If given, is a setter, otherwise, it's getter.
    • source: [view]
         if(typeof toEnable != "undefined"){
          this.__enabled = !!toEnable;
         }
         return this.__enabled; //Boolean
    • summary
      The get/set function of the enabled status of this layer
    • tags:
    • returns
      Boolean
  • dojox.grid.enhanced.plugins._StoreLayer.name

    • type
      Function
    • source: [view]
         if(!this.__name){
          var m = this.declaredClass.match(/(?:\.(?:_*)([^\.]+)Layer$)|(?:\.([^\.]+)$)/i);
          this.__name = m ? (m[1] || m[2]).toLowerCase() : this.declaredClass;
         }
         return this.__name;
    • summary
      Get the name of this store layer.
      The default name retrieved from class name, which should have a pattern of "{name}Layer".
      If this pattern does not exist, the whole class name will be this layer's name.
      It's better to override this method if your class name is too complicated.
    • tags:
    • return_summary
      The name of this layer.
  • dojox.grid.enhanced.plugins._StoreLayer.originFetch

    • type
      Function
    • source: [view]
         return (dojo.hitch(this._store, this._originFetch)).apply(this, arguments);
    • summary
  • dojox.grid.enhanced.plugins._StoreLayer._funcName

    • summary
  • dojox.grid.enhanced.plugins._StoreLayer.__name

    • summary
  • dojox.grid.enhanced.plugins._ServerSideLayer

    • type
      Function
    • chains:
      • ns._StoreLayer: (prototype)
      • ns._StoreLayer: (call)
    • summary
      The most abstract class for all server side store layers.
      tags:
      abstract
    • parameters:
      • args: (typeof )
    • source: [view]
         args = args || {};
         this._url = args.url || "";
         this._isStateful = !!args.isStateful;
         this._onUserCommandLoad = args.onCommandLoad || function(){};
         this.__cmds = {cmdlayer:this.name(), enable:true};

         
         //Only for stateful server, sending commands before fetch makes sense.
         this.useCommands(this._isStateful);
  • dojox.grid.enhanced.plugins._ServerSideLayer._url

    • tags: protected
    • type
      string
    • summary
      The url of the server
  • dojox.grid.enhanced.plugins._ServerSideLayer.__cmds

    • type
      Object
    • summary
  • dojox.grid.enhanced.plugins._ServerSideLayer.enabled

    • type
      Function
    • parameters:
      • toEnable: (typeof bool)
    • source: [view]
         var res = this.inherited(arguments);
         this.__cmds.enable = this.__enabled;
         return res;
    • summary
      Overrided from _StoreLayer.enabled
  • dojox.grid.enhanced.plugins._ServerSideLayer.useCommands

    • type
      Function
    • parameters:
      • toUse: (typeof bool)
        Boolean?
        If provided, it's a setter, otherwise, it's a getter
    • source: [view]
         if(typeof toUse != "undefined"){
          this.__cmds.cmdlayer = (toUse && this._isStateful) ? this.name() : null;
         }
         return !!(this.__cmds.cmdlayer); //Boolean
    • summary
      If you only want to modify the user request, instead of sending a separate command
      to server before fetch, just call:
      this.useCommand(false);
    • tags:
    • returns
      Boolean
  • dojox.grid.enhanced.plugins._ServerSideLayer._fetch

    • type
      Function
    • parameters:
      • userRequest: (typeof keywordArgs)
    • source: [view]
         if(this.__cmds.cmdlayer){
          //We're gonna send command to server before fetch.
          dojo.xhrPost({
           url: this._url || this._store.url,
           content: this.__cmds,
           load: dojo.hitch(this, function(responce){
            this.onCommandLoad(responce, userRequest);
            this.originFetch(userRequest);
           }),
           error: dojo.hitch(this, this.onCommandError)
          });
         }else{
          //The user only wants to modify the request object.
          this.onCommandLoad("", userRequest);
          this.originFetch(userRequest);
         }
         return userRequest; //dojo.data.api.Request
    • summary
      Implementation of _StoreLayer._fetch
    • returns
      dojo.data.api.Request
  • dojox.grid.enhanced.plugins._ServerSideLayer.command

    • type
      Function
    • parameters:
      • cmdName: (typeof string)
        The name of the command
      • cmdContent: (typeof (string|number|bool|.)
        anything
        The content of the command
    • source: [view]
         var cmds = this.__cmds;
         if(cmdContent === null){
          delete cmds[cmdName];
         }else if(typeof cmdContent !== "undefined"){
          cmds[cmdName] = cmdContent;
         }
         return cmds[cmdName]; //anything
    • summary
      get/set a command (a name-value pair)
    • tags:
    • return_summary
      The content of the command if cmdContent is undefined
    • returns
      anything
  • dojox.grid.enhanced.plugins._ServerSideLayer.onCommandLoad

    • type
      Function
    • parameters:
      • response: (typeof string)
        server response
      • userRequest: (typeof keywordArgs)
        in|out] dojo.data.api.Request
        The request object for *fetch*. You can modify this object according to the *response*
        so as to change the behavior of *fetch*
    • source: [view]
         this._onUserCommandLoad(this.__cmds, userRequest, response);
    • summary
      When the server gives back *response* for the commands, you can do something here.
    • tags:
  • dojox.grid.enhanced.plugins._ServerSideLayer.onCommandError

    • type
      Function
    • parameters:
      • error: (typeof Error)
    • source: [view]
         console.log(error);
         throw error;
    • summary
      handle errors when sending commands.
    • tags:
  • dojox.grid.enhanced.plugins._ServerSideLayer.__cmds.enable

    • summary
  • dojox.grid.enhanced.plugins._ServerSideLayer.__cmds.cmdlayer

    • summary
  • dojox.grid.enhanced.plugins._ServerSideLayer._isStateful

    • summary
  • dojox.grid.enhanced.plugins._ServerSideLayer._onUserCommandLoad

    • summary
  • ns.wrap

    • summary
  • getPrevTags

    • type
      Function
    • parameters:
      • tags: (typeof )
    • source: [view]
        var tagList = ["reorder", "sizeChange", "normal", "presentation"];
        var idx = tagList.length;
        for(var i = tags.length - 1; i >= 0; --i){
         var p = dojo.indexOf(tagList, tags[i]);
         if(p >= 0 && p <= idx){
          idx = p;
         }
        }
        if(idx < tagList.length - 1){
         return tagList.slice(0, idx + 1);
        }else{
         return tagList;
        }
    • summary
  • unwrap

    • type
      Function
    • parameters:
      • layerName: (typeof string)
    • source: [view]
        var i, layers = this._layers, len = layers.length;
        if(layerName){
         for(i = len-1; i >= 0; --i){
          if(layers[i].name() == layerName){
           layers[i]._unwrap(layers[i + 1]);
           break;
          }
         }
         layers.splice(i, 1);
        }else{
         for(i = len - 1; i >= 0; --i){
          layers[i]._unwrap();
         }
        }
        if(!layers.length){
         delete this._layers;
         delete this.layer;
         delete this.unwrap;
         delete this.forEachLayer;
        }
        //console.log("layers:",this._layers);
        return this; //Read-store
    • summary
      Unwrap the layers of the store
    • tags:
    • return_summary
      The unwrapped store, for nested use only.
    • returns
      Read-store
  • getLayer

    • type
      Function
    • parameters:
      • layerName: (typeof string)
        the name of the layer
    • source: [view]
        var i, layers = this._layers;
        if(typeof layerName == "undefined"){
         return layers.length; //Integer
        }
        if(typeof layerName == "number"){
         return layers[layerName]; //_StoreLayer
        }
        for(i = layers.length - 1; i >= 0; --i){
         if(layers[i].name() == layerName){
          return layers[i]; //_StoreLayer
         }
        }
        return null; //_StoreLayer
    • summary
      Get a layer of the store, so we can configure that layer.
    • tags:
    • return_summary
      the store layer object
    • returns
      Integer|_StoreLayer
  • forEachLayer

    • type
      Function
    • parameters:
      • callback: (typeof Function)
        The function to callback.
        If return false, break the loop.
      • isInnerToOuter: (typeof Boolean)
        Whether visit from the inner most layer to the outer most layer.
    • source: [view]
        var len = this._layers.length, start, end, dir;
        if(isInnerToOuter){
         start = 0;
         end = len;
         dir = 1;
        }else{
         start = len - 1;
         end = -1;
         dir = -1;
        }
        for(var i = start; i != end; i += dir){
         if(callback(this._layers[i], i) === false){
          return i;
         }
        }
        return end;
    • summary
      Visit the layers one by one. From the outer most to inner most by default.
  • dojox.grid.enhanced.plugins

    • type
      Object
    • summary
  • dojox.grid.enhanced

    • type
      Object
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary