在做库房管理系统的过程中要求点击表格最后一列归还物品,如下图所示:
下面就介绍一下如何给easyui中操作列添加按钮:
function click() {
//判断文本框输入是否为空
if ($('#bb').value = "") {
alert("商品不能为空");
return;
}
var outgoing = $("#bb").val();
$('#dg').datagrid({
//datagrid分页-李娜-2017年8月23日14:40:16
//把搜索框中的内容提交到后台对数据进行过滤
url: '/Return/ShowBorrowInfo?itemName=' + outgoing, //获取数据地址
//data: "password=" + $("#bb").val(),
dataType: 'json',
width: "100%", //宽度
striped: true, //把行条纹化(奇偶行背景色不同)
idField: 'quesID', //标识字段
loadMsg: '正在加载用户的信息.......', //从远程站点加载数据是,显示的提示消息
pagination: true, //数据网格底部显示分页工具栏
singleSelect: false, //只允许选中一行
pageList: [10, 20, 30, 40, 50], //设置每页记录条数的列表
pageSize: 10, //初始化页面尺寸(默认分页大小)
pageNumber: 1, //初始化页面(默认显示第一页)
beforePageText: '第', //页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '第{from}到{to}条,共{total}条',
columns: [[ //每页具体内容
{
field: 'quesID', //列的字段名(数据库)
title: '题目编号', //列的标题文本
editor: 'text', //编辑类型
hidden: true, //隐藏该列
fit: true //自适应宽度
},
{ field: 'ItemNo', title: '商品编号', editor: 'text' },
{ field: 'ItemName', title: '商品名称', editor: 'text' },
{ field: 'CategoryID', title: '商品类别', editor: 'text' },
{ field: 'Number', title: '借用数量', editor: 'text' },
{ field: 'Purpose', title: '用途', editor: 'text' },
{ field: 'Operator1', title: '审批人', editor: 'text' },
{ field: 'LendingDate', title: '借用时间', editor: 'text' },
{ field: 'ReturnDate', title: '归还时间', editor: 'text' },
//格式化操作列
{field: 'OperationItem', title: '操作列', formatter: btnDetailed}
]]
})
}
function btnDetailed(value, rowData, rowIndex) {
if (typeof rowData.OperationItem == "string") {
return '<input type="button" value="归还;" class="easyui-linkbutton" iconCls="icon-edit" plain="true" style="width:50px;height:20px;" />';
}
}
界面显示:
在牛腩系统中我们把某一列设置成按钮是这样的:
<h3>类别管理</h3>
<div class="con">
<div class="fontcolor">提示:点击类别名称可以直接修改类别</div>
<table class="m_table">
<tr>
<th class="xuhao">序号</th>
<th class="ca">类别名称</th>
<th class="delete">操作</th>
</tr>
<asp:Repeater ID="repCategory" runat="server">
<ItemTemplate>
<tr>
<td><%# Eval ("id") %></td>
<td class="caname"><%# Eval ("name") %></td>
//把该列设置成linkbutton
<td>
<asp:LinkButton ID="lbtnDelCa" runat="server" CommandArgument='<%# Eval ("id") %>' OnClientClick="return confirm('删除类别会使其下的新闻和评论全都删除,是否真的要删除?')" OnClick="lbtnDelCa_Click">删除</asp:LinkButton></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
</div>
在牛腩系统中我们把某一列设置成按钮是这样的:刚开始我想直接在view界面把他设置成按钮不就行了吗?
<td>
<input id="btn_Return" type="button" value="归还" onclick ="Return;" />
</td>
在牛腩系统中我们把某一列设置成按钮是这样的:这样在加载的时候可以显示:
在牛腩系统中我们把某一列设置成按钮是这样的:但是当我们点击搜索按钮的时候,在js里面会动态加载页面,这时显示出来的会把前面的页面所覆盖,从而使得按钮失效。所以应该在js里面动态添加按钮。