javascript 对datagrid的一些操作

<script language="javascript">
   function OnPreSave()
   {
    var message="";
    var objTable=document.getElementById("dgrdList");
    for(var i=0;i<objTable.rows.length-2;i++)
    {
     var idSum = parseInt(i)+parseInt(2);
     var idNum = parseInt(i)+parseInt(1);
     var zpTextId = "dgrdList__ctl" + idSum +"_SelfAppraiseNum";
     var kpTextId = "dgrdList__ctl" + idSum +"_VerifyAppraiseNum";
     var bzTextId = "dgrdList__ctl" + idSum +"_Remark";
     if(parseInt(document.getElementById(kpTextId).value) == document.getElementById(kpTextId).value && parseInt(document.getElementById(kpTextId).value)>=0)
     {     
     }
     else
     {
      alert("第"+ idNum + "行,考评分请输入非负数的数字!");
      return;
     }
     if(parseInt(document.getElementById(kpTextId).value) != parseInt(document.getElementById(zpTextId).value) && document.getElementById(bzTextId).value.replace(" ","") == "")
     {
      message += "," + idNum;
     }     
    }
    if(message!="")
    {
     alert("第"+ message.substring(1) + "行,考评分与自评分不同,该条备注必须填写!");
     return;
    }
    else
    {
     document.all("btnSave").onclick();
    }
   }
   function getData()
   {
    var objTable=document.getElementById("dgrdList");
    var kpSum = 0;
    var zpSum = 0;

    for(var i=0;i<objTable.rows.length-2;i++)
    {
     var idSum = parseInt(i)+parseInt(2);
     var idNum = parseInt(i)+parseInt(1);
     var kpTextId = "dgrdList__ctl" + idSum +"_VerifyAppraiseNum";
     var zpTextId = "dgrdList__ctl" + idSum +"_SelfAppraiseNum";
     if(parseInt(document.getElementById(kpTextId).value) == document.getElementById(kpTextId).value && parseInt(document.getElementById(kpTextId).value)>=0)
     {
      kpSum = parseInt(kpSum) + parseInt(document.getElementById(kpTextId).value);
      zpSum = parseInt(zpSum) + parseInt(document.getElementById(zpTextId).value);
     }
     else
     {
      alert("第"+ idNum + "行,考评分请输入非负数的数字!");
      return;
     }
    }
    if(objTable.rows[0].cells.length > 8)
    {
     objTable.rows[objTable.rows.length-1].cells[8].innerText = zpSum;
     objTable.rows[objTable.rows.length-1].cells[9].innerText = kpSum;
    }
    else
    {
     objTable.rows[objTable.rows.length-1].cells[6].innerText = zpSum;
     objTable.rows[objTable.rows.length-1].cells[7].innerText = kpSum;
    }
   }

 

function OnSum()
   {
    var objTable=document.getElementById("dgrdList");
    var zpSum = 0;

    for(var i=0;i<objTable.rows.length-2;i++)
    {
     var idSum = parseInt(i)+parseInt(2);
     var idNum = parseInt(i)+parseInt(1);
     var zpTextId = "dgrdList__ctl" + idSum +"_SelfAppraiseNum";
     if(parseInt(document.getElementById(zpTextId).value) == document.getElementById(zpTextId).value && parseInt(document.getElementById(zpTextId).value)>=0)
     {
      zpSum = parseInt(zpSum) + parseInt(document.getElementById(zpTextId).value);
     }
     else
     {
      alert("第"+ idNum + "行,自评分请输入非负数的数字!");
      return;
     }
    }
    if(objTable.rows[0].cells.length > 8)
    {
     objTable.rows[objTable.rows.length-1].cells[8].innerText = zpSum;
    }
    else
    {
     objTable.rows[objTable.rows.length-1].cells[6].innerText = zpSum;
    }
   }


  </script>

posted @ 2008-07-23 16:02  jenner  阅读(590)  评论(0编辑  收藏  举报