因工作需要,需要对ecside中的一些不可见的列进行赋值,也取值的需求。对ecside.js的函数进行了扩展
/**用于对 cell进行赋值(用于hidden列)
* currRow 当前行
* name 列名
* sValue:值
* tableId:表名
* 作者:yangxp
* 日期: 20090210
* */
ECSideUtil.setHiddenPropertyValue=function(currRow, name, sValue,tableId)
{
if(arguments.length>3 && tableId !=undefined && tableId !="" )
{
ECSideUtil.tableId = tableId;
}
var theadName = ECSideUtil.tableId+"_table_head";
var thead = document.getElementById(theadName);
var cellIndex = -1;
var flag = false;
if(thead !=null)
{
var cells = thead.rows[0].cells;
for(var i=0; i<cells.length; i++)
{
if(cells[i].getAttribute("columnname")!=null)
{
if(ECSideUtil.trimString(cells[i].getAttribute("columnname")) == ECSideUtil.trimString(name))
{
cellIndex = cells[i].cellIndex;
ECSideUtil.updateCell(currRow.cells[cellIndex]);
currRow.cells[cellIndex].setAttribute("cellValue",sValue);
currRow.setAttribute("edited","true");
flag = true;
break;
}
}
}
}
if(!flag)
{
alert("setPropertyValue设计属性出错,请检查列名是否正确!");
return;
}
}
/**给编辑的Cell赋值innerText (用于显示列)
* editCell 编辑的INPUT
* currRow 当前行
* name 要赋值的列名
* sValue 赋的值
* tableId 表名
* 作者:yangxp
* 日期:20090210
* */
ECSideUtil.setUpdatePropertyValue=function(editCell,currRow,name,sValue)
{
editCell.innerText = sValue;
ECSideUtil.updateEditCell(editCell);
}
/**往编辑的Cell中插入数据** (用于新增列)
* currRow 当前行
* name:列名
* sValue 值
* 作者:yangxp
* 日期:20090210
* */
ECSideUtil.setInsertProperty=function(currRow,name,sValue)
{
var cells = currRow.cells;
var flag = false;
for(var i=0; i<cells.length; i++)
{
if(cells[i].innerHTML.indexOf("name="+name)>0)
{
cells[i].childNodes[0].innerText = sValue;
flag = true;
break;
}
}
if(!flag)
{
alert("setInsertProperty()函数设置属性出错,请检查列名是否正确!");
return;
}
}
/**得到某列的值
* currRow 当前行
* naem:列名
* tableId :表名
* 日期:20090210
*/
ECSideUtil.getProperty=function(currRow, name,tableId)
{
if(arguments.length>3 && tableId !=undefined && tableId !="")
{
ECSideUtil.tableId = tableId;
}
var theadName = ECSideUtil.tableId+"_table_head";
var thead = document.getElementById(theadName);
var cellIndex = -1;
var flag = false;
if(thead !=null)
{
var cells = thead.rows[0].cells;
for(var i=0; i<cells.length; i++)
{
if(cells[i].getAttribute("columnname")!=null)
{
if(ECSideUtil.trimString(cells[i].getAttribute("columnname")) == ECSideUtil.trimString(name))
{
cellIndex = cells[i].cellIndex;
var ss = currRow.cells[cellIndex].innerText;
flag = true;
break;
}
}
}
}
if(!flag)
{
alert("getPropertyValue出错,请检查列名是否正确!");
return;
}
return ss;
}
/**
* 行上移
* 日期:20090217
*/
ECSideUtil.MoveUp=function(currRow)
{
var index = currRow.rowIndex
var tb = currRow.parentNode.parentNode;
if(index!=0)
{
tb.moveRow(index,index-1);
}else
{
alert("已经是最上面了")
}
}
/**
* 往下移动行
* @param {} currRow
* 日期:20090219
*/
ECSideUtil.MoveDown=function(currRow)
{
var index = currRow.rowIndex
var tb = currRow.parentNode.parentNode;
if(index!=tb.rows.length-1)
{
tb.moveRow(index,index+1);
}else
{
alert("已经是最下面了")
}
}