解决方案 »

  1.   

    return "<a href='javascript:void(0)' onclick='addryxx("+JSON.stringify(row)+")' >编辑</a>"传递index就好了,你JSON.stringify会传递一个新的json对象,而且如果你的row内容包含单引号回导致你的html代码出错,更新这个对象无用传递index可以获取getRows获取所有行通过index下标获取到数据
    return "<a href='javascript:void(0)' onclick='addryxx("+index+")' >编辑</a>"
    var editIndex=-1;
    function addryxx(index){
       var row= $('#fzmc').datagrid('getRows')[index];
      //打开dialog,给你的dialog里面的表单赋值什么的
     editIndex=index;//////////更新正在编辑的数据下标
    }dialog的保存后获取表单数据,调用updateRow更新datagrid数据
    function save(){
       $('#fzmc').datagrid('updateRow',{index:editIndex,row:{/*字段名和表单的键值对对象*/}}
    }updateRow  param  Update the specified row, the param contains following properties:
    index: the row index to be updated.
    row: the new row data.Code example:$('#dg').datagrid('updateRow',{
    index: 2,
    row: {
    name: 'new name',
    note: 'new note message'
    }
    });
    有空对看下API,http://www.jeasyui.com/documentation/index.php
      

  2.   

    太感谢了 终于搞定了 就是还有一个小问题
     var editIndex=-1;
            function addryxx(index){
            var row= $('#fzmc').datagrid('getRows')[index];
            editIndex=index;         
              $('#window').window({      
                     title:'编辑分组人员信息',   
                     width:350,    
                     height:400,    
                     modal:true,     
               }); 
                 if(row){
                    if(row.xm){
                        document.getElementById("xm").value = row.xm;
                    }
                     if(row.xb){
                        document.getElementById("xb").value = row.xb;
                    }                if(row.sfzhm){
                        document.getElementById("sfzhm").value = row.sfzhm;
                    }
                    if(row.csny){
                        document.getElementById("csny").value = row.csny;
                    }
                    if(row.dz){
                        document.getElementById("dz").value = row.dz;
                    }
                    if(row.mz){
                        document.getElementById("mz").value = row.mz;
                    }
                    if(row.lxdh){
                        document.getElementById("lxdh").value = row.lxdh;
                    }
                    if(row.bm){
                        document.getElementById("bm").value = row.bm;
                    }
              }
              }
              function checkboxsave(){
                 $('#fzmc').datagrid('updateRow',{index:editIndex,row:{
                        xm:document.getElementById("xm").value,
                        xb:document.getElementById("xb").value,
                        sfzhm:document.getElementById("sfzhm").value,
                        csny:document.getElementById("csny").value,
                        dz:document.getElementById("dz").value ,
                        mz:document.getElementById("mz").value,
                        lxdh:document.getElementById("lxdh").value,
                        bm:document.getElementById("bm").value
                  }});
                  $('#window').window('close');  
        //          $('#fzmc').datagrid('reload');
              }
    ----------------------------------
    if(row){         这的row是指所有行,而不是单击的这一行 ,导致窗口里面原有的数据混乱了 用什么方法让它指定行
      

  3.   

     var row= $('#fzmc').datagrid('getRows')[index];不会是所有行啊,依据传入的index获取的行。。
      

  4.   

    if(row){
                     if(row.xm){
                         document.getElementById("xm").value = row.xm;
                     }
    如果这一行的“xm”为空的话 它还会显示出其他行的“xm”
    。。
    这个怎么搞啊  想了好久了
    搞了一晚上了 都搞不定
      

  5.   


    你做了删除操作?要不不可能后去到其他行的数据的。如果确实是做了删除操作。。删除的记录在你编辑的数据行前面确实会导致获取到下一行的数据(删除越多越推后)不行你传递此行的id进入addryxx,遍历所有数据获取到自定的数据行,这样就不怕删除了return "<a href='javascript:void(0)' onclick='addryxx("+row["你的id列名称"]+")' >编辑</a>"var rowId=-1
            function addryxx(id){
            var rows= $('#fzmc').datagrid('getRows'),row=false;
    for(var i=0;i<rows.length;i++)if(rows[i]["id键名称"]==id){row=rows[i];break;}
    if(row==false){alert('找不到编辑的数据行!');return}
     rowId=id;///////save也差不多,通过id找到row,代码和上面一样,然后调用getRowIndex  得到编辑的数据行下标,注意数据行id和编辑的数据行下标不是同一个东西
      

  6.   

    确实做了删除  
    return "<a href='javascript:void(0)' onclick='addryxx("+row["你的id列名称"]+")' >编辑</a>"
    row["你的id列名称"]   这个是什么啊  这个表没有id啊 你能详细点不 。。我菜鸟 
      

  7.   


    你数据表没有id键吗?将id键一起放到json字符串中发送到客户端。。要不传递身份证那个列值应该也是唯一的,身份证应该没有重复的。要是有重复的你只能用id键了