解决问题办法来自 http://www.coding123.net/article/20141113/easyui-datagrid-datailview-use-sub-datagrid-not-align.aspx
$("#MsgListDiv").datagrid({ view: detailview, detailFormatter:function(index,row){ return '<div style="padding:2px;width:1100"><table class="ddv"><tr></table></div>'; }, onExpandRow: function(index,row){ var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv'); ddv.datagrid({ url: 'json/FaultMainten_queryFM.action?flag=1&pid=' + row.pid, fitColumns:false, singleSelect:true, rownumbers:true, loadMsg:'', height:'auto', columns:[[ {field:'pname',title:'监测点名称',width:120,align:'center'}, {field:'maintainer',title:'维护人员',width:70,align:'center'}, {field:'maintainerTel',title:'电话',width:90,align:'center'}, {field:'faultReason',title:'故障原因',width:70,align:'center'}, {field:'hardwareReason',title:'硬件原因',width:80,align:'center'}, {field:'softwareReason',title:'软件原因',width:80,align:'center'}, {field:'repairData',title:'保修日期',width:130,align:'center'}, {field:'processMode',title:'处理方式',width:90,align:'center'}, {field:'processResult',title:'处理结果',width:90,align:'center'}, {field:'processData',title:'处理日期',width:130,align:'center'}, {field:'processContent',title:'具体处理内容',width:110,align:'center'} ]], onResize: function(){ $('#MsgListDiv').datagrid('fixDetailRowHeight',index); }, onLoadSuccess:function(){ setTimeout(function(){ var tr = ddv.closest('tr'), //获取子表格所在行 id = tr.prev().attr('id'); //此子表格父行所在行的id id = id.replace(/-2-(\d+)$/, '-1-$1'); //detailview没有展开的前部分的id是有规则的 $('#' + id).next().css('height', tr.height());//设置没展开的前部分的高度,由于启用了计时器,会闪一下 }, 1); //$('MsgListDiv').datagrid('fixDetailRowHeight',index); //},0); }, onDblClickRow: function(rowIndex, rowData) { //双击事件 view(rowData.id); } }); $('#MsgListDiv').datagrid('fixDetailRowHeight',index); } });