📄 treegrid.js
字号:
profile.getSubNode('COLLIST').css({visibility:'hidden',left:0,top:0});
});
}
},
COLLIST:{
onMouseover:function(profile,e,src){
_.resetRun(profile.$id+':collist',null);
},
onMouseout:function(profile,e,src){
_.resetRun(profile.$id+':collist',function(){
linb([src]).css('visibility','hidden');
});
},
onClick:function(profile,e,src){
if(!profile.properties.colHidable)return;
if(!profile.$col_pop){
var items=[],pop;
_.arr.each(profile.properties.header,function(o){
if(('colHidable' in o)?o.colHidable:1)
items.push({id:o.id,caption:o.caption,type:'checkbox',value:true});
});
pop=profile.$col_pop=new linb.UI.PopMenu({hideAfterClick:false,items:items}).render(true);
pop.onMenuSelected(function(p,i,s){
var b=1;
_.arr.each(p.properties.items, function(o){
if(o.value!==false)
return b=false;
});
if(!b){
profile.boxing().showColumn(i.id, i.value);
profile.box._ajdustBody(profile);
}else{
p.getSubNodeByItemId('CHECKBOX',i.id).tagClass('-checked');
i.value=true;
}
})
}
profile.$col_pop.pop(src);
}
},
CELLS:{
afterMouseover:function(profile, e, src){
if(profile.properties.activeMode=='row')
linb([src]).tagClass('-mouseover');
},
afterMouseout:function(profile, e, src){
if(profile.properties.activeMode=='row')
linb([src]).tagClass('-mouseover',false);
},
onDblclick:function(profile, e, src){
var p = profile.properties,
row = profile.rowMap[profile.getSubId(src.id)];
if(p.disabled || row.disabled)return false;
if(profile.onDblClickRow)profile.boxing().onDblClickRow(profile, row, e, src);
return false;
},
onClick:function(profile){
var p = profile.properties,
row = profile.rowMap[profile.getSubId(this.id)];
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:{
onDblclick:function(profile, e, src){
var cell = profile.cellMap[profile.getSubId(src.id)];
if(!cell)return;
var box=profile.box,
getPro=box.getCellPro,
type=getPro(profile, cell, 'type'),
disabled=getPro(profile, cell, 'disabled'),
editable=getPro(profile, cell, 'editable');
if(!disabled && (!editable || (type=='button'||type=='label')))
profile.boxing().onDblClickCell(profile, cell, e, src);
},
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,
editable=getPro(profile, cell, 'editable'),
id;
if(!disabled && (!editable || (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(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){
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.innerHTML=''+tag+i;
if(o.firstChild)
o.firstChild.nodeValue
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -