You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.5 KiB
141 lines
4.5 KiB
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
|
|
|
|
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
|
|
MultiList
|
|
</asp:Content>
|
|
|
|
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
|
|
|
<h2>MultiList</h2>
|
|
<script type="text/javascript">
|
|
|
|
$(function () {
|
|
|
|
var $dg = $("#dg");
|
|
|
|
$dg.datagrid({
|
|
|
|
url: "/Examples/GetRows",
|
|
|
|
toolbar: [{
|
|
|
|
text: "添加",
|
|
|
|
iconCls: "icon-add",
|
|
|
|
handler: function () {
|
|
|
|
$dg.datagrid('appendRow', {});
|
|
|
|
var rows = $dg.datagrid('getRows');
|
|
|
|
$dg.datagrid('beginEdit', rows.length - 1);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
text: "编辑",
|
|
|
|
iconCls: "icon-edit",
|
|
|
|
handler: function () {
|
|
|
|
var row = $dg.datagrid('getSelected');
|
|
|
|
if (row) {
|
|
|
|
var rowIndex = $dg.datagrid('getRowIndex', row);
|
|
|
|
$dg.datagrid('beginEdit', rowIndex);
|
|
|
|
}
|
|
}
|
|
|
|
}, {
|
|
|
|
text: "删除",
|
|
|
|
iconCls: "icon-remove",
|
|
|
|
handler: function () {
|
|
|
|
var row = $dg.datagrid('getSelected');
|
|
if (row) {
|
|
var rowIndex = $dg.datagrid('getRowIndex', row);
|
|
$dg.datagrid('deleteRow', rowIndex);
|
|
}
|
|
}
|
|
}, {
|
|
text: "结束编辑",
|
|
iconCls: "icon-cancel",
|
|
handler: endEdit
|
|
}, {
|
|
text: "保存",
|
|
iconCls: "icon-save",
|
|
handler: function () {
|
|
endEdit();
|
|
if ($dg.datagrid('getChanges').length) {
|
|
var rows = $dg.datagrid("getRows");
|
|
|
|
|
|
document.getElementById("dgRows").value = JSON.stringify(rows);
|
|
|
|
var myform = $('form');
|
|
myform.attr("action", "/Examples/SaveMultiList");
|
|
myform.submit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
function endEdit() {
|
|
|
|
var rows = $dg.datagrid('getRows');
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
$dg.datagrid('endEdit', i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
<% using (Html.BeginForm()) { %>
|
|
<table id="dg" style="width:650px;height:auto"
|
|
title="Editable DataGrid" iconCls="icon-edit" singleSelect="true"
|
|
idField="itemid" url="datagrid_data2.json">
|
|
<thead>
|
|
<tr>
|
|
<th field="UserID" width="80" align="right" editor="text">Unit Cost</th>
|
|
<th field="UserName" width="150" editor="text">Attribute</th>
|
|
<th field="UserDes1" width="60" align="center" editor="text">Status</th>
|
|
<th field="UserDes2" width="60" align="center" editor="text">Status</th>
|
|
<th field="UserDes3" width="60" align="center" editor="text">Status</th>
|
|
<th field="UserDes4" width="60" align="center" editor="text">Status</th>
|
|
<th field="UserDes5" width="60" align="center" editor="combobox">Status</th>
|
|
<th field="UserDes6" width="60" align="center" editor="combobox">Status</th>
|
|
<th field="UserDes7" width="60" align="center" editor="combobox">Status</th>
|
|
<th field="UserDes8" width="60" align="center" editor="text">Status</th>
|
|
<th field="UserDes9" width="60" align="center" editor="datebox">Status</th>
|
|
<th field="UserDes10" width="60" align="center" editor="datebox">Status</th>
|
|
<th field="UserDes11" width="60" align="center" editor="datebox">Status</th>
|
|
<th field="UserDes12" width="60" align="center" editor="datebox">Status</th>
|
|
<th field="UserDes13" width="60" align="center" editor="datebox">Status</th>
|
|
<th field="UserDes14" width="60" align="center" editor="text">Status</th>
|
|
|
|
</tr>
|
|
</thead>
|
|
</table>
|
|
<input id="dgRows" name="dgRows" type="hidden" />
|
|
<% } %>
|
|
</asp:Content>
|
|
|