全部展开:
var me = this;
setTimeout(function () {
//延时触发easyui datagrid detailviewclick事件,
不用计时器无法展开,不懂什么问题~
$(me).parent().find('span.datagrid-row-expander').trigger('click');
//没效果注意修改这里的选择器
}, 10);
行内datagrid添加一行时,外层的datagrid也需要添加一行。
/*添加明细 */
function addReimbursementDetail(index){
/*!!! */
var rows=$('#applyChaoddv-'+index).datagrid("getRows");
var indexnew;
if(rows!=null){
indexnew=rows.length;
}else{
indexnew=0
}
$('#applyChaoddv-'+index).datagrid('appendRow',{
row: {
}
});
$('#applyChaoddv-'+index).datagrid('beginEdit', indexnew);
/* 外层 */
$('#feiyongbaoxiao').datagrid('fixDetailRowHeight',index);
}
全部展开样式问题:
在行内的datagrid onLoadSuccess事件中添加
id为行外的加载datagrid的div的id,index为展开时传过来的索引号。
setTimeout(function(){
$('#feiyongbaoxiao').datagrid('fixDetailRowHeight',index);
},0);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if($("#feiyongbaoxiao").length==0){
var ajax="<div id='feiyongbaoxiao'></div>";
$("#feiyongbaoxiao1234512").append(ajax);
$("#feiyongbaoxiao").datagrid({
url:'<%=path%>/reimbursementController/findProjectIndirectMeasureend.do',
idField:'ReimbursementId',
rownumbers:true,
fitColumn: false,
singleSelect : true,
fit: false,
queryParams: {
IndirectMeasuresId:rembursement,
projectId:project,
projectReimbursementorderId:projectReimbursementorderId
},
//columns: columns,
columns:[[
{field:'Description',title:'费用名称',align:'center',width:160,editor:{type:'validatebox'}},
{field:'applyRmark',title:'事由说明',align:'center',width:160,editor:{type:'validatebox'}},
{field:'theApplyMoney',title:'申请金额',width:250,align:'center',editor:{type:'validatebox',options:{}}},
{field:'thereimbursementAmount',title:'本次报销金额',align:'center',width:160,editor:{type:'validatebox',options:{}}},
{field:'ReimbursementAmount',title:'已报销金额',align:'center',width:160,editor:{type:'validatebox',options:{}}},
{field:'action',title:'操作', align : 'center',width:180,
formatter:function(val, rowData, index){
var textValue='';
if(rowData.palaverid != ''||rowData.palaverid != null){
textValue='<a href="javascript:addReimbursementDetail(\''+index+'\',1); " style="text-decoration:none" class="atooltip">添加明细</a>';
//textValue='<a href="javascript:delete1();" style="text-decoration:none">删除</a>';
};
return textValue;
}
}
]],
onLoadSuccess:function(data){
var me = this;
setTimeout(function () {//延时触发easyui datagrid detailviewclick事件,不用计时器无法展开,不懂什么问题~
$(me).parent().find('span.datagrid-row-expander').trigger('click'); //没效果注意修改这里的选择器
}, 10);
var rows=data.rows;
if(rows!=null&&rows.length!=0){
for(var i=0;i<rows.length;i++){
if(rows[i].thereimbursementAmount>rows[i].theApplyMoney){
$("#datagrid-row-r1-2-"+i).css("color","red");
/* 模糊匹配 */
$("tr[id*='datagrid-row-r']").css("color","red");
}
}
}
},
view: detailview,
detailFormatter:function(index,row){
return '<table id="applyChaoddv-'+index+'"></table>';
},
onExpandRow: function(parentIndex,row){
/*开始 */
$('#applyChaoddv-'+parentIndex).datagrid({
url : '<%=path%>/reimbursementController/findReimbursementDetailed.do',
queryParams: {
reimbursementId:row.reimbursementId,
projectReimbursementorderId:projectReimbursementorderId
},
iconCls: 'icon-save', //图标
fit: false, //datagrid自适应宽度
fitColumns: true, //列自适应宽度
striped: true, //行背景交换
nowap: false, //列内容多时自动折至第二行
border: true,
idField: 'bqitemid', //主键
frozenColumns : [ [ {
field : 'bqitemid',
width : 10,
align : 'center',
} ] ],
columns:[[
{field:'reimbursementDetailedRemark',title:'事由说明',align:'center',width:250,editor:{type:'validatebox'}},
{field:'reimbursementDetailedAmount',title:'报销金额',align:'center',width:250,editor:{type:'numberbox',options:{precision:2}}},
{field:'action',title:'操作', align : 'center',width:200,
formatter:function(val, rowData, index){
var textValue='';
if(rowData.palaverid != ''||rowData.palaverid != null){
textValue="<a href='javascript:delete111(\""+index+"\",\""+parentIndex+"\");' style='text-decoration:none'>删除</a>";
//textValue='<a href="javascript:delete111(\''+index+'\','');" style="text-decoration:none">删除</a>';
};
return textValue;
}
}
]] ,
onDblClickCell: function(index,field,value){
$(this).datagrid('beginEdit', index);
},
onResize:function(){
$('#feiyongbaoxiao').datagrid('fixDetailRowHeight',parentIndex);
},
onLoadSuccess:function(data){
var rows=data.rows;
var theReimbursementAmount=0.0;
if(rows!=null&&rows.length!=0){
for(var i=0;i<rows.length;i++){
var row=rows[i];
theReimbursementAmount+=row.reimbursementDetailedAmount;
}}
$("#datagrid-row-r1-2-"+parentIndex+" td[field=thereimbursementAmount]>div").text(theReimbursementAmount);
setTimeout(function(){
$('#feiyongbaoxiao').datagrid('fixDetailRowHeight',parentIndex);
},0);
}
});
$('#applyChaoddv-'+parentIndex).datagrid("reload");
/* 结束 */
},
onCollapseRow:function(index,row){
$('#applyChaoddv-'+index).datagrid("reload");
}
});}else{
$("#feiyongbaoxiao").datagrid("reload",{
IndirectMeasuresId:rembursement,
projectId:project,
projectReimbursementorderId:projectReimbursementorderId
});
}