国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET MVC使用EasyUI的datagrid多選提交保存教程

2024-07-10 12:41:40
字體:
來源:轉載
供稿:網友
需要實現EasyUI的datagrid組件加入選擇checkbox列,并提交后臺批量添加的功能,頁面代碼如下:
代碼如下:
<script language="javascript" type="text/javascript">
$(function() {
//searchbox
$('#selectgoods-keywords').searchbox({
searcher: function(val, name) {
searchInfo(val);
}
});
//datagrid
$('#selectgoods-grid').datagrid({
url: '/Goods/List',
pageNumber: 1,
pageSize: 20,
pageList: [20, 40, 60, 80, 100]
});
//form
});
function searchInfo(val){
// var keytype=$('#keyType').combobox('getValue');
var keytype = 'Goods_Name';
var keywords = val;
$('#selectgoods-grid').datagrid('reload', { keytype: keytype, keywords: keywords });
}
function saveSelectGoods() {
var ids = [];
var rows = $('#selectgoods-grid').datagrid('getSelections');
for (var i = 0; i < rows.length; i++) {
ids.push(rows[i].Identifier);
}
var selectsupplier = '<%=ViewData["supplier"] %>';
$.post('/SupplierGoods/SaveSelect', { supplier: selectsupplier, checks: ids.join(',') }, function(data) {
if (data) {
$('#goodslist-grid').datagrid('reload');
$('#goodsInfo-window').window('close');
} else {
alert('保存失敗!');
}
}, 'json');
}
</script>
<div style="width:100%; height:100%">
<table id="selectgoods-grid" class="easyui-datagrid" fit="true" toolbar="#tlb_selectgoods_search" pagination="true"
rownumbers="true" fitColumns="true" idField="Identifier">
<thead>
<tr>
<th field="ck" checkbox="true"></th>
<th field="Identifier" hidden="true" width="0" editor="text">Id</th>
<th field="Goods_Name" width="100" editor="{type:'validatebox',options:{required:true}}">商品名稱</th>
<th field="Chemistry" width="100" editor="{type:'validatebox',options:{required:true}}">化學指標</th>
<th field="Physical" width="100" editor="{type:'validatebox',options:{required:true}}">物理指標</th>
<th field="Partner_Name" width="50" editor="{type:'validatebox',options:{required:true}}">合作狀態</th>
</tr>
</thead>
</table>
<div id="tlb_selectgoods_search">
商品名稱:<input name="keywords" id="selectgoods-keywords" class="easyui-searchbox" /><a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:saveSelectGoods()">保存</a>
</div>
</div>

ASP.NET MVC的Controller代碼如下:
代碼如下:
/// <summary>
/// 多選商品添加
/// </summary>
/// <param name="supplier">供貨商ID</param>
/// <returns></returns>
public ActionResult SelectGoods(string supplier)
{
ViewData["supplier"] = supplier;
return View();
}
/// <summary>
/// 保存批量添加的產品信息
/// </summary>
/// <param name="checks">選中的商品ID</param>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 辉县市| 鄱阳县| 桐梓县| 土默特右旗| 六盘水市| 安庆市| 莱州市| 赤城县| 玉树县| 宜君县| 沁源县| 清丰县| 老河口市| 革吉县| 武定县| 兴海县| 宁晋县| 黄大仙区| 德昌县| 襄汾县| 望奎县| 攀枝花市| 大姚县| 贵港市| 城固县| 宁德市| 滨海县| 伽师县| 潜江市| 铁力市| 互助| 新建县| 黔江区| 西城区| 剑川县| 阜阳市| 天台县| 余姚市| 阿城市| 通道| 进贤县|