var html = '<img id=' + id + 'img src=images/' + id.replace(/btn/,'') + '.gif></img>';
if(!eval(element.smallbuttons)){
var btntext = text[id.replace(/btn/,'') + 'text'];
html = '<table cellpadding=0 cellspacing=0><tr><td align=center>' + html + '<td></tr><tr><td style="font-size:8pt">' + btntext + '</td></tr></table>';
var key = btntext.tolowercase().match(/<u>(.*)<\/u>/);
if(key)
accesskey = 'accesskey=' + key[1];
}
return '<button class=lv id=' + id + ' ' + accesskey + '>' + html + '</button>';
}
/**
* listview属性改变时调用
*/
function propertychange(){
switch(event.propertyname){
case 'updaterow':
case 'search':
case 'save':
case 'rowinfo':
case 'pageinfo':
case 'insertrow':
case 'deleterow':
case 'editrow':
case 'copy':
case 'help':
case 'columnpicker':
case 'sort':
case 'print':
eval("toolbar.all." + event.propertyname + "cell.style.display = (" + event.propertyname + ".tostring().tolowercase() == 'true') ? '' : 'none'");
break;
case 'buttonnavigation':
for (var i in navbuttons)
eval("toolbar.all." + navbuttons[i] + "cell.style.display = (buttonnavigation.tostring().tolowercase() == 'true') ? '' : 'none'");
break;
default:
}
if(event.propertyname == 'displaytoolbar')
toolbar.childnodes[0].style.display = eval(displaytoolbar) ? '' : 'none';
}
/**
* 显示listview数据
*
* 从lvdata和lvhead数组画listview
*/
function drawdata(){
_lvelement('listtable').innerhtml = '<table width="100%" border=0 cellspacing=0 cellpadding=0 ><tr><td bgcolor="#000000"><table id="idlvdata" border="0" cellspacing="1" cellpadding="2" width="100%"></table></td></tr></table>';
element.table = _lvelement('idlvdata');
rowcount = lvdata.length;
//计算总页数
pagecount = math.ceil(rowcount/pagesize);
var otr,otd;
//画listview表头
otr = table.insertrow();
for(var i=0; i<lvhead.length; i++){
otd = otr.insertcell(i);
if(eval(wrapheadings)) otd.nowrap = true;
otd.classname = lvhead[i]._style;
otd.innerhtml = lvhead[i]._value;
if(ordercolumn != "" && lvhead[i]._columnname == lvhead[ordercolumn]._columnname){
otd.innerhtml += " <img src=images/" + lvhead[i]._ordersequence + ".gif>";
}
//增加单击事件
if(lvdata.length>0)
otd.onclick = reorder;
}
//数据体为空时返回
if(lvdata.length == 0) return;
//根据当前页数画显示listview数据
for(var r=(pagenumber-1)*pagesize; r<pagenumber*pagesize; r++){
if(r>=rowcount) break;
otr = table.insertrow();
for(var c=0; c<lvdata[r].length; c++){
otd = otr.insertcell(c);
if(eval(wrapheadings)) otd.nowrap = true;
//判断是否格式数据
if(typeof(lvformat[lvhead[c]._columnname]) != "undefined"){
otd.innerhtml = lvformat[lvhead[c]._columnname][lvdata[r][c]._value];
}
else{
otd.innerhtml = lvdata[r][c]._value;
}
//设置该位置的样式
setstyle(otd,lvdata[r][c]._style);
//设置改位置单击事件
otd.onclick = selectrow;
}
}
//修改工具栏数据
configuretoolbar(pagecount);
}
/**
* 设置某个具体数据格的样式
*
* 参数:
* el: 数据格对象
* style: 样式
*/
function setstyle(el,style){
try{
var arr_style = style.split(";");
for(var i=0;i<arr_style.length;i++){
var fields = arr_style[i].split(":");
el.style.setattribute(fields[0],fields[1]);
}
}
catch(e){
//缺省样式
el.style.setattribute("backgroundcolor","white");
el.style.setattribute("color","blank");
el.style.setattribute("cursor","defaule");
alert(e);
}
}
/**
* listview数据格对象
* 参数:
* value: 数据值