⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treegrid.js

📁 axjx工具代码给大家交流
💻 JS
📖 第 1 页 / 共 5 页
字号:
                    if(row.group)
                        profile.getSubNode('TOGGLE',row._serialId).onClick();
                }
            },
            CELL:{
                afterMouseover:function(profile, e, src){
                    if(profile.properties.activeMode=='cell')
                        linb([src]).tagClass('-mouseover');
                },
                afterMouseout:function(profile, e, src){
                    if(profile.properties.activeMode=='cell')
                        linb([src]).tagClass('-mouseover',false);
                }
            },
            CELLA:{
                onClick:function(profile, e, src){
                    var cell = profile.cellMap[profile.getSubId(src.id)];
                    if(!cell)return;
                    var p = profile.properties,
                        box=profile.box,
                        getPro=box.getCellPro,
                        type=getPro(profile, cell, 'type'),
                        disabled=getPro(profile, cell, 'disabled'),
                        event=getPro(profile, cell, 'event'),
                        mode = p.activeMode, id, type,event;

                    if(!disabled && (type=='button'||type=='label')){
                        if(typeof event == 'function' && false===event.call(profile._host||profile, profile, cell, null,null,e,src)){}
                        else
                            profile.boxing().onClickCell(profile, cell, e, src);
                        if(type=='button')
                            return false;
                    }
                    if(!disabled &&type=='checkbox')
                        if(getPro(profile, cell, 'editable'))
                            box._updCell(profile, cell, !cell.value);
                    if(!p.editable){
                        if(mode=='cell'){
                            if(getPro(profile, cell, 'disabled'))
                                return false;
                            id = linb(src).parent().id();
                            box._sel(profile, 'cell', src, id, e);
                        }else if(mode=='row'){
                            if(p.disabled || cell._row.disabled)
                                return false;
                            id = linb(src).parent(2).id();
                            box._sel(profile, 'row', src, id, e);
                        }
                    }
                    //ie6: if 'a' has a child 'span', you click 'span' will not tigger to focus 'a'
                    src.focus();
                    return false;
                },
                onFocus:function(profile, e, src){
                    var p = profile.properties,
                        box=profile.box,
                        getPro=box.getCellPro,
                        cell = profile.cellMap[profile.getSubId(src.id)],
                        mode = p.activeMode, id;

                    if(getPro(profile, cell, 'editable')){
                        if(getPro(profile, cell, 'disabled'))
                            return false;
                        box._editCell(profile, cell._serialId);
                        _.asyRun(function(){
                            linb([src.parentNode,src.parentNode.parentNode]).onMouseout(true,{$force:true});
                        });
                    }
                    if(!p.editable){
                        if(mode=='cell'){
                            id = linb(src).parent().id();
                            box._activeCell(profile, id);
                        }else if(mode=='row'){
                            id = linb(src).parent(2).id();
                            box._activeRow(profile, id);
                        }
                    }
                },
                onKeydown:function(profile, e, src){
                    var keys=linb.Event.getKey(e),
                        key = keys[0],
                        shift=keys[2],
                        cur = linb(src),
                        body = profile.getSubNode('BODY'),
                        first = body.nextFocus(true, true, false),
                        last = body.nextFocus(false, true, false);
                    switch(key){
                    //tab to next/pre
                    case 'tab':
                        if(shift){
                            if(src!=first.get(0)){
                                first.focus();
                                return false;
                            }
                        }else{
                            if(src!=last.get(0)){
                                last.focus();
                                return false;
                            }
                        }
                        break;
                    case 'left':
                        if(cur.get(0)==first.get(0))
                            last.focus();
                        else
                            cur.nextFocus(false);
                        return false;
                        break;
                    case 'right':
                        if(cur.get(0)==last.get(0))
                            first.focus();
                        else
                            cur.nextFocus();
                        return false;
                        break;
                    case 'up':
                        if(cur.get(0)==first.get(0)){
                            last.focus();
                            return;
                        }
                   case 'down':
                        //get no.
                        var count=1,
                            temp = cur.parent().get(0),
                            max=temp.parentNode.childNodes.length;
                        while(temp=temp.previousSibling)count++;

                        //get row
                        temp=cur.parent(2).get(0);

                        //get all rows(include header)
                        if(!profile.$allrowscache){
                            var all=profile.getSubNode('CELLS',true).get();
                            //filter dispaly==none
                            _.filter(all,function(o){
                                return !!o.offsetWidth;
                            });
                            profile.$allrowscache = all;
                        }

                        //get index
                        var index = _.arr.indexOf(profile.$allrowscache,temp),
                            rowLen = profile.$allrowscache.length;

                        //adjust index
                        if(key=='up'){
                            index--;
                            if(index==-1){
                                index = rowLen-1;
                                count--;
                                if(count==0)count=max;
                            }
                        }else{
                            index++;
                            if(index==rowLen){
                                index=0;
                                count++;
                                if(count==max+1)count=1;
                            }
                        }

                        //get node
                        node = linb(profile.$allrowscache[index]).first().next(count-1).first();
                        if(!node.isEmpty())
                            node.focus();
                        return false;
                        break;
                    }
                }
            },
            FIRSTCELL:{
                onClick:function(profile, e, src){
                    var p = profile.properties,
                        row = profile.rowMap[profile.getSubId(this.id)];
                    if(!row.group)
                        profile.getSubNode('TOGGLE',row._serialId).onClick();
                }
            }
        },
        DataModel:{
            listKey:null,
            tabindex:{
                action:function(value){
                    this.root.query('A').attr('tabIndex',value);
                }
            },
            selMode:{
                ini:'none',
                listbox:['single','none','multi']
            },
            dock:'fill',

            altRowsBg: {
                ini:false,
                action:function(value){
                    var ns=this;
                    if(ns.domNode){
                        var altCls = ns.getClass('ALT'),
                            nodes = ns.getSubNode('CELLS',true),alt,j;
                        nodes.removeClass(altCls);
                        if(value){
                            alt=[];
                            j=0;
                            nodes.each(function(o,i){
                                if(o.offsetHeight){
                                    o=linb([o]);
                                    if((j++)%2==1){
                                        if(!o.hasClass(altCls))o.addClass(altCls);
                                    }else{
                                        if(o.hasClass(altCls))o.removeClass(altCls);
                                    }
                                }
                            });
                            linb(alt).addClass(altCls);
                        }
                    }
                }
            },
            rowNumbered:{
                ini:false,
                action:function(value){
                    var ns=this;
                    if(ns.domNode){
                        var nodes = ns.getSubNode('FIRSTCELLNO',true),i=0,map=ns.rowMap,row,ol=0,l=0,a1=[],a2=[],tag='',temp;
                        nodes.each(function(o){
                                o.innerHTML='';
                                if(o.parentNode.offsetHeight){
                                    row=map[ns.getSubId(o.id)];
                                    l=row._layer;
                                    if(l>ol){
                                        a1.push(i);
                                        a2.push(tag);
                                        tag=tag+i+'.';
                                        i=0;
                                    }else if(l<ol){
                                        while(l<ol--){
                                            i=a1.pop();
                                            tag=a2.pop();
                                        }
                                    }
                                    i++;
                                    ol=l;
                                    o.appendChild(document.createTextNode(tag+i));
                                }
                        });
                    }
                }
            },
            editable:false,

            $subMargin:16,

            iniFold:true,
            animCollapse:false,

            left:0,
            top:0,
            position:'absolute',
            width:300,
            height:200,

            _minColW:5,
            _maxColW:300,
            _minRowH:20,
            _row0DfW: 32,
            showHeader:{
                ini:true,
                action:function(value){
                    this.getSubNode('HEADER').css('display',value?'':'none');
                }
            },
            headerHeight:{
                ini:20,
                action:function(v){
                    this.getSubNode('HCELLS').height(v);
                    linb.UI.$tryResize(this, this.root.width(), this.root.height());
                }
            },
            rowHeight:{
                ini:20,
                action:function(v){
                    this.getSubNode('CELLS', true).height(v);
                }
            },
            _colDfWidth: 80,

            rowHandler:{
                ini:true,
                action:function(value){
                    this.getSubNode('HCELL0').css('display',value?'':'none');
                    this.getSubNode('FIRSTCELL',true).css('display',value?'':'none');
                }
            },
            rowResizer:{
                ini:true,
                action:function(value){
                    this.getSubNode('ROWHANDLER',true).css('display',value?'':'none');
                }
            },

            colHidable:false,
            colResizer:{
                ini:true,
                action:function(value){
                    this.getSubNode('HHANDLER',true).css('display',value?'':'none');
                }
            },
            colSortable:{
                ini:true,
                action:function(value){
                    this.getSubNode('SORT',true).css('display',value?'':'none');
                }
            },
            colMovable:false,

            header:{
                ini:{},
                set:function(value){
                    return this.each(function(o){
                        if(o.domNode){
                            o.boxing()._refreshHeader(value);
                        }else
                            o.properties.head

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -