function editrow(index) {
$.messager.alert(index);
$('#tt').datagrid('beginEdit', index);
}为什么index是undefined?我是通过点击表格“编辑”链接。

解决方案 »

  1.   


    $(function(){
    var grid = new easyui.datagrid({
    title:"商品列表",
    renderer:"gridlist",
    onBeforeEdit:function(index,row) { 
    row.editing = true; 
    //$(this).datagrid("selectRow",index);
    $(this).datagrid("refreshRow",index); 
    }, 
    onAfterEdit:function(index,row) { 
    row.editing = false; 
    //$(this).datagrid("selectRow",index);
    $(this).datagrid("refreshRow",index); 
    }, 
    onCancelEdit:function(index,row) { 
    row.editing = false; 
    $(this).datagrid("refreshRow",index); 
    },
    /* 是否支持双击打开编辑
    onDblClickCell:function(index,field,value) {
    $(this).datagrid("beginEdit",index); 
    $(this).dategrid("getEditor",{index:index,field:"LOWER_LIMIT"});
    },
    */
    columns:[[
    {title:"物品ID",field:"GOODS_ID",width:30,hidden:true},
    {title:"库存警戒值",field:"LOWER_LIMIT",width:100,align:"center",editor:"numberbox"},
    {title:"操作",field:"opera",width:120,align:"center",formatter:
    function(value,row,index) {
    if(row.editing) {
    var s = "<a href='#' onclick='save(" + index + ")'>保存</a>";
    var c = "<a href='#' onclick='cancel(" + index + ")'>取消</a>"; 
    return s + "&nbsp" + "&nbsp" + c;
    } else {
    var e = "<a href='#' onclick='edit(" + index + ")'>编辑</a>";
    return e ; 
    }
    }
    },
    ]],
    });
    已贴!
      

  2.   

    另问:如何获取datagrid中某一列的全部值,并保存到数组中?是用getEditor吗?