easyUI框架之学习3--表格datagrid

@model MVCEasyUI.Models.Sale.PageResult<MVCEasyUI.Models.Sale.Order>
@{
ViewBag.Title = "AddSaleOrder";
}
<!DOCTYPE html>
<html>
<head >
<link href="~/Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" />
<link href="~/Scripts/easyUI/themes/icon.css" rel="stylesheet" />
<script src="~/Scripts/easyUI/jquery-1.7.2.min.js"></script>
<script src="~/Scripts/easyUI/jquery.easyui.min.js"></script>
<script src="~/Scripts/easyUI/locale/easyui-lang-zh_CN.js"></script>
<script >
var _id = 1;
$(function () {

}); function AppendRow() {
_id++;
var objId = 'tmp_' + _id;
var tmp = "<div id=" + objId + "><a href='#' class='easyui-linkbutton' data-options='iconCls:\"icon-remove\"' >删除</a> <a href='#' class='easyui-linkbutton' data-options='iconCls:\"icon-edit\"' >编辑</a></div>";
 
$('#OrderList').datagrid('appendRow', {
CorId: 0,
PlatfromId: 1,
ShopId: 2,
Opr:tmp
});
var obj = $("#" + objId);
$.parser.parse(obj);

}

function DeleteRow() {
var row = $('#OrderList').datagrid('getSelected');
alert(row);
if (row) {
var index = $('#OrderList').datagrid('getRowIndex', row);
$('#OrderList').datagrid('deleteRow', index);
}
}


</script>
</head>

<body >
<h2>@Model.ResultName</h2>
<a href="#" onclick ="AppendRow()">添加一行</a>
<table id="OrderList" class="easyui-datagrid">
<thead >
<tr >
<th data-options="field:'CorId'">商家ID</th>
<th data-options="field:'PlatfromId'">平台ID</th>
<th data-options="field:'ShopId'">店铺ID</th>
<th data-options="field:'TreadId'">交易编号</th>
<th data-options="field:'TreadTime'">交易时间</th>
<th data-options="field:'Opr'">操作</th>
</tr>

</thead>
<tbody >
@foreach (var order in Model.ResultList)
{
<tr id="Id@{@order.Id}">
<td id="CorId_@order.CorId">@order.CorId </td>
<td><a id="PlatfromId_@order.PlatfromId" href ="#">@order.PlatfromId </a></td>
<td><a id="ShopId_@order.ShopId" href ="#">@order.ShopId</a> </td>
<td>@order.TreadId </td>
<td>@order.TreadTime </td>
<td> <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-remove'" onclick='DeleteRow()'>删除</a>
<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick=''>编辑</a>

</td>
</tr>
}
</tbody>

</table>
</body>
</html>

posted @ 2015-11-27 16:16  zslm___  阅读(247)  评论(0编辑  收藏  举报