有列表 想添加一个操作列 类似删除之类的
<table class="easyui-datagrid" title="编码列表" style="width:500px; min-height: 0px;" id="Hsdata">
<thead>
<tr>
<th data-options="field:'HsCode',width:100">编码</th>
<th data-options="field:'StartDate',width:150">开始日期</th>
<th data-options="field:'EndDate',width:150,align:'结束日期'">结束日期</th>
<th data-options="field:'IsImporter',width:100,align:'是否进口数据'">是否进口数据</th>
<th data-options="field:'IsDemoData',width:100">是否演示数据</th>
<th data-options="field:'Id',width:100,formatter: rowformater,onClickRow:delHsCode">操作</th>
</tr>
</thead>
</table>通过formatter方法给Jquery easyui 的datagrid 每行增加操作链接
//删除
function rowformater(value, row, index) {
return '<a href="#" onclick="delHsCode(' + index + ')">删除</a>';
}
return '<a href="'+row["ID"]+'">修改</a>'; 我改了一下 在onclick方法中绑定方法 因为如果用之前的传value row index 三个参数会导致自动触发 所以改动了一下
function delHsCode(index) {
$('#Hsdata').datagrid('selectRow', index);
var row = $('#Hsdata').datagrid('getSelected');
if (row.Id != null && row.Id !== undefined)
alert(row.Id);
}以下为效果图:

本文介绍如何在easyUI的datagrid中自定义添加包含操作按钮的列,如删除功能,通过JS实现。
1116

被折叠的 条评论
为什么被折叠?



