dojox/grid/TreeSelection.js

  • Provides:

    • dojox.grid.TreeSelection
  • Requires:

    • dojox.grid.DataSelection in common
  • dojox.grid.TreeSelection

    • type
      Function
    • chains:
      • dojox.grid.DataSelection: (prototype)
      • dojox.grid.DataSelection: (call)
    • summary
  • dojox.grid.TreeSelection.setMode

    • type
      Function
    • parameters:
      • mode: (typeof )
    • source: [view]
        this.selected = {};
        this.sorted_sel = [];
        this.sorted_ltos = {};
        this.sorted_stol = {};
        dojox.grid.DataSelection.prototype.setMode.call(this, mode);
    • chains:
      • dojox.grid.DataSelection.prototype.setMode: (call)
    • summary
  • dojox.grid.TreeSelection.addToSelection

    • type
      Function
    • parameters:
      • inItemOrIndex: (typeof )
    • source: [view]
        if(this.mode == 'none'){ return; }
        var idx = null;
        if(typeof inItemOrIndex == "number" || typeof inItemOrIndex == "string"){
         idx = inItemOrIndex;
        }else{
         idx = this.grid.getItemIndex(inItemOrIndex);
        }
        if(this.selected[idx]){
         this.selectedIndex = idx;
        }else{
         if(this.onCanSelect(idx) !== false){
          this.selectedIndex = idx;
          var rowNodes = dojo.query("tr[dojoxTreeGridPath='" + idx + "']", this.grid.domNode);
          if(rowNodes.length){
           dojo.attr(rowNodes[0],"aria-selected","true");
          }
          this._beginUpdate();
          this.selected[idx] = true;
          this._insertSortedSelection(idx);
          //this.grid.onSelected(idx);
          this.onSelected(idx);
          //this.onSetSelected(idx, true);
          this._endUpdate();
         }
        }
    • summary
  • dojox.grid.TreeSelection.deselect

    • type
      Function
    • parameters:
      • inItemOrIndex: (typeof )
    • source: [view]
        if(this.mode == 'none'){ return; }
        var idx = null;
        if(typeof inItemOrIndex == "number" || typeof inItemOrIndex == "string"){
         idx = inItemOrIndex;
        }else{
         idx = this.grid.getItemIndex(inItemOrIndex);
        }
        if(this.selectedIndex == idx){
         this.selectedIndex = -1;
        }
        if(this.selected[idx]){
         if(this.onCanDeselect(idx) === false){
          return;
         }
         var rowNodes = dojo.query("tr[dojoxTreeGridPath='" + idx + "']", this.grid.domNode);
         if(rowNodes.length){
          dojo.attr(rowNodes[0],"aria-selected","false");
         }
         this._beginUpdate();
         delete this.selected[idx];
         this._removeSortedSelection(idx);
         //this.grid.onDeselected(idx);
         this.onDeselected(idx);
         //this.onSetSelected(idx, false);
         this._endUpdate();
        }
    • summary
  • dojox.grid.TreeSelection.getSelected

    • type
      Function
    • source: [view]
        var result = [];
        for(var i in this.selected){
         if(this.selected[i]){
          result.push(this.grid.getItem(i));
         }
        }
        return result;
    • summary
  • dojox.grid.TreeSelection.getSelectedCount

    • type
      Function
    • source: [view]
        var c = 0;
        for(var i in this.selected){
         if(this.selected[i]){
          c++;
         }
        }
        return c;
    • summary
  • dojox.grid.TreeSelection._bsearch

    • type
      Function
    • parameters:
      • v: (typeof )
    • source: [view]
        var o = this.sorted_sel;
        var h = o.length - 1, l = 0, m;
        while(l<=h){
         var cmp = this._comparePaths(o[m = (l + h) >> 1], v);
         if(cmp < 0){ l = m + 1; continue; }
         if(cmp > 0){ h = m - 1; continue; }
         return m;
        }
        return cmp < 0 ? m - cmp : m;
    • summary
  • dojox.grid.TreeSelection._comparePaths

    • type
      Function
    • parameters:
      • a: (typeof )
      • b: (typeof )
    • source: [view]
        for(var i=0, l=(a.length < b.length ? a.length : b.length); i   if(a[i]   if(a[i]>b[i]){ return 1; }
        }
        if(a.length  if(a.length>b.length){ return 1; }
        return 0;
    • summary
  • dojox.grid.TreeSelection._insertSortedSelection

    • type
      Function
    • parameters:
      • index: (typeof )
    • source: [view]
        index = String(index);
        var s = this.sorted_sel;
        var sl = this.sorted_ltos;
        var ss = this.sorted_stol;


        var lpath = index.split('/');
        lpath = dojo.map(lpath, function(item){ return parseInt(item, 10); });
        sl[lpath] = index;
        ss[index] = lpath;


        if(s.length === 0){
         s.push(lpath);
         return;
        }
        if(s.length==1){
         var cmp = this._comparePaths(s[0], lpath);
         if(cmp==1){ s.unshift(lpath); }
         else{ s.push(lpath); }
         return;
        }


        var idx = this._bsearch(lpath);
        this.sorted_sel.splice(idx, 0, lpath);
    • summary
  • dojox.grid.TreeSelection._removeSortedSelection

    • type
      Function
    • parameters:
      • index: (typeof )
    • source: [view]
        index = String(index);
        var s = this.sorted_sel;
        var sl = this.sorted_ltos;
        var ss = this.sorted_stol;


        if(s.length === 0){
         return;
        }


        var lpath = ss[index];
        if(!lpath){ return; }


        var idx = this._bsearch(lpath);
        if(idx > -1){
         delete sl[lpath];
         delete ss[index];
         s.splice(idx, 1);
        }
    • summary
  • dojox.grid.TreeSelection.getFirstSelected

    • type
      Function
    • source: [view]
        if(!this.sorted_sel.length||this.mode == 'none'){ return -1; }
        var fpath = this.sorted_sel[0];
        if(!fpath){
         return -1;
        }
        fpath = this.sorted_ltos[fpath];
        if(!fpath){
         return -1;
        }
        return fpath;
    • summary
  • dojox.grid.TreeSelection.getNextSelected

    • type
      Function
    • parameters:
      • inPrev: (typeof )
    • source: [view]
        if(!this.sorted_sel.length||this.mode == 'none'){ return -1; }
        inPrev = String(inPrev);
        var prevPath = this.sorted_stol[inPrev];
        if(!prevPath){ return -1; }


        var idx = this._bsearch(prevPath);
        var lpath = this.sorted_sel[idx+1];
        if(!lpath){
         return -1;
        }
        return this.sorted_ltos[lpath];
    • summary
  • dojox.grid.TreeSelection._range

    • type
      Function
    • parameters:
      • inFrom: (typeof )
      • inTo: (typeof )
      • func: (typeof )
    • source: [view]
        if(!dojo.isString(inFrom) && inFrom < 0){
         inFrom = inTo;
        }
        var cells = this.grid.layout.cells,
         store = this.grid.store,
         grid = this.grid;
        inFrom = new dojox.grid.TreePath(String(inFrom), grid);
        inTo = new dojox.grid.TreePath(String(inTo), grid);


        if(inFrom.compare(inTo) > 0){
         var tmp = inFrom;
         inFrom = inTo;
         inTo = tmp;
        }


        var inFromStr = inFrom._str, inToStr = inTo._str;


        // select/deselect the first
        func(inFromStr);


        var p = inFrom;
        while((p = p.next())){
         if(p._str == inToStr){
          break;
         }
         func(p._str);
        }


        // select/deselect the last
        func(inToStr);
    • summary
  • dojox.grid.TreeSelection.selected

    • summary
  • dojox.grid.TreeSelection.sorted_sel

    • summary
  • dojox.grid.TreeSelection.sorted_ltos

    • summary
  • dojox.grid.TreeSelection.sorted_stol

    • summary
  • dojox.grid.TreeSelection.mode

    • summary
  • dojox.grid.TreeSelection.selectedIndex

    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary