easy-ui 小白进阶史(二):操作数据,easy-ui操作
easy-ui的操作及交互:
Html:
@using LangBo.Facade;
@using LangBo.DataDefine;
@using System.Threading.Tasks;
@model List<FR_CategoryInfo>
@{
ViewBag.Title = "小组管理";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section scripts {
<script src="@Url.Content("~/Scripts/Community/TopicMng.js")" type="text/javascript"></script>
}
<div id="main">
<div class="frame-top"> </div>
<div class="frame-list">
<table id="topiclist"></table> //加载数据
</div> </div> <div id="pop_Topic">
<div class="popinner">
<input type="hidden" name="Id" value="" />
<table class="frame-main">
<tr class="line">
<td class="title">小组类型</td>
<td class="content">
<select name="CategoryID" >
@foreach (FR_CategoryInfo category in Model)
{
<option value="@category.Id">@category.CategoryName</option>
}
</select>
</td>
<tr class="line">
<td class="title">小组名称</td>
<td class="content"><input name="TopicCont" value="" /></td>
</tr>
<tr class="line">
<td class="title">期数</td>
<td class="content"><input name="PeriodIndex" value="" /></td>
</tr>
<tr class="line">
<td class="title">小组排序</td>
<td class="content"><input name="TopicIndex" value="" /></td>
</tr>
<tr class="line">
<td class="title">权限</td>
<td class="content">
<select name="PurviewLevel" value="">
<option value="0">特权小组</option>
<option value="1">普通小组</option>
</select>
</td>
</tr>
</table>
<div class="actionbar-full">
//操作 与js中 InitPageEvent()相对应
<a href="javascript:void(0)" data-act="cancel" class="easyui-linkbutton" iconcls="icon-back">取消</a>
<a href="javascript:void(0)" data-act="save" class="easyui-linkbutton" iconcls="icon-ok">保存</a>
</div>
</div>
</div>
js:
$(document).ready(function () {
TopicMgr.InitPageEvent();
TopicMgr.InitPageCtrl();
TopicMgr.InitPageData();
});
var TopicMgr = {
InitPageEvent: function () {
$("#pop_Topic .actionbar-full a[data-act=save]").on("click", function () {
TopicMgr.SaveTopic();
});
$("#pop_Topic .actionbar-full a[data-act=cancel]").on("click", function () {
TopicMgr.CancelEditTopic();
});
},
InitPageCtrl: function () { //隐藏添加弹出框
$("#pop_Topic").dialog({ modal: true, closed: true });
},
InitPageData: function () {
$("#topiclist").datagrid({
url: "/Community/Topic/List",
title: "小组管理",
width: 980,
height: 760,
loadMsg: "加载中....",
fitColumns: false,
rownumbers: true,
singleSelect: true,
idField: "Id",
columns: [[
{ field: "Id", title: "ID", width: 50, align: "left" },
{ field: "CategoryName", title: "小组类别", width: 80, align: "left" },
{ field: "TestTypeName", title: "考试类型", width: 80, align: "left" },
{ field: "TopicCont", title: "小组名称", width: 90, align: "left" },
{ field: "TopicDesc", title: "简介", width: 150, align: "left" },
{ field: "PeriodIndex", title: "当前期数", width: 70, align: "left" },
{ field: "TopicIndex", title: "小组排序", width: 70, align: "left" },
{ field: "CreatorName", title: "创始人", width: 100, align: "left" },
{
field: "PurviewLevel", title: "权限", width: 80, align: "left",
formatter: function (value) {
return value == 0 ? "特权小组" : "普通小组"
}
},
{
field: "TimeMark", title: "创建时间", width: 110, align: "left",
formatter: function (value) {
return FormatJSONDateToDate(value);
}
},
//进行操作
{
field: "Op", title: "操作", width: 150, align: "left",
formatter: function (value, rec, rowIdx) {
return "<a href='javascript:TopicMgr.EditTopic()' style='margin-right: 10px'>编辑</a>" +
"<a href='javascript:TopicMgr.DeleteTopic(" + rowIdx + ")'>删除</a>";
}
},
]],
///添加
toolbar: [{
text: "添加",
iconCls: "icon-add",
handler: function () {
TopicMgr.AppendTopic();
}
}]
});
},
AppendTopic: function () {
$("#pop_Topic input[name=Id]").val("");
$("#pop_Topic input[name=CategoryID]").val("");
$("#pop_Topic input[name=TestType]").val("");
$("#pop_Topic input[name=TopicCont]").val("");
$("#pop_Topic input[name=CreatorID]").val("");
$("#pop_Topic textarea[name=TopicDesc]").text("");
$("#pop_Topic input[name=TimerMark]").val("");
$("#pop_Topic input[name=PurviewLevel]").val("");
$("#pop_Topic input[name=PeriodIndex]").val("");
$("#pop_Topic input[name=TopicIndex]").val("");
$("#pop_Topic").dialog({ title: "添加信息" });
$("#pop_Topic").dialog("open");
},
EditTopic: function () {
TryAutoFillControl($("#topiclist").datagrid("getSelected"), "pop_Topic");
$("#pop_Topic").dialog({ title: "编辑信息" });
$("#pop_Topic").dialog("open");
},
SaveTopic: function () {
var dataCarrier = new Object();
dataCarrier.topic = SerializeFormObjs($("#pop_Topic :input").serializeArray());
var postUrl;
if (dataCarrier.topic.Id == "")
postUrl = "/Community/Topic/Insert"; //添加
else postUrl = "/Community/Topic/Update"; //修改
$.ajax({
type: "POST",
url: postUrl,
data: JSON.stringify(dataCarrier),
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (result) {
$("#topiclist").datagrid("reload");
$("#pop_Topic").dialog("close");
$.messager.alert("提示", result, "info");
},
error: function (ex) {
$.messager.alert('提示', "操作失败", "error");
}
});
},
DeleteTopic: function (index) {
//操作删除 传参到C#
$.messager.confirm("提示", "你确定删除此条记录吗?", function (r) {
if (r) {
$.ajax({
type: "POST",
url: "/Community/Topic/Delete",
data: "{ 'topicID': '" + $("#topiclist").datagrid("getSelected").Id + "' }",
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (result) {
$("#topiclist").datagrid("deleteRow", index);
$.messager.alert("提示", result, "info");
},
error: function (ex) {
$.messager.alert('提示', "操作失败", "error");
}
});
}
});
},
//关闭弹出框
CancelEditTopic: function () {
$("#pop_Topic").dialog("close");
}
}
C#:
public async Task<ActionResult> TopicMng() {
if (CurrentUser.GetCurrentUserPurview(CurrentUser.UserPurview_Community)) {
List<FR_CategoryInfo> listCategory = await CommunityTopicFacade.ListCategory().ConfigureAwait(false);
return View(listCategory);
} else
return Redirect("~/Home/Error");
}
public async Task<JsonResult> List() {
return new JsonResult() {
Data = await CommunityTopicFacade.ListAsync().ConfigureAwait(false)
};
}
public async Task<JsonResult> Insert(FR_TopicInfo topic) {
topic.CreatorID = CurrentUser.GetCurrentUserID();
topic.PeriodIndex = 1;
await CommunityTopicFacade.InsertAsync(topic).ConfigureAwait(false);
return new JsonResult() {
Data = "添加数据成功"
};
}
public async Task<JsonResult> Update(FR_TopicInfo topic) {
topic.CreatorID = CurrentUser.GetCurrentUserID();
await CommunityTopicFacade.UpdateAsync(topic).ConfigureAwait(false);
return new JsonResult() {
Data = "修改数据成功"
};
}
public async Task<JsonResult> Delete(string topicID) {
await CommunityTopicFacade.DeleteAsync(topicID).ConfigureAwait(false);
return new JsonResult() {
Data = "删除数据成功"
};
}
easy-ui 小白进阶史(二):操作数据,easy-ui操作的更多相关文章
- easy-ui 小白进阶史(一):加载数据,easy-ui显示
作为一个没上过大学,没经过正规培训的96年的小白来说,找工作就没报特别大的希望,大不了找不到在回炉重造,继续学... 终于在海投了200份的简历之后...终于找到了...面试也挺简单的,,,第二天就去 ...
- TensorFlow进阶(二)---张量的操作
张量操作 在tensorflow中,有很多操作张量的函数,有生成张量.创建随机张量.张量类型与形状变换和张量的切片与运算 生成张量 固定值张量 tf.zeros(shape, dtype=tf.flo ...
- Android高手进阶教程(二十八)之---Android ViewPager控件的使用(基于ViewPager的横向相册)!!!
分类: Android高手进阶 Android基础教程 2012-09-14 18:10 29759人阅读 评论(35) 收藏 举报 android相册layoutobjectclassloade ...
- iOS进阶指南试读之UI篇
iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...
- css进阶之二:flex弹性布局
布局模式是指一个盒子与其兄弟.祖先盒的关系决定其尺寸与位置的算法.css2.1中定义了四种布局模式,分别是块布局.行内布局.表格布局.以及定位布局.css3引入了新的布局模式Flexbox布局,灵活度 ...
- Wireshark入门与进阶系列(二)
摘自http://blog.csdn.net/howeverpf/article/details/40743705 Wireshark入门与进阶系列(二) “君子生非异也,善假于物也”---荀子 本文 ...
- ”Metro UI之磁贴(二)
也来“玩”Metro UI之磁贴(二) 继昨天的“也来“玩”Metro UI之磁贴(一)”之后,还不过瘾,今天继续“玩”吧——今天把单选的功能加进来,还有磁贴的内容,还加了发光效果(CSS3,IE9+ ...
- Redis 小白指南(二)- 基础命令和五大类型:字符串、散列、列表、集合和有序集合
Redis 小白指南(二)- 基础命令和五大类型:字符串.散列.列表.集合和有序集合 引言 目录 基础命令 字符串类型 散列类型 列表类型 集合类型 有序集合类型 基础命令 1.获得符合规则的键名列表 ...
- SpringBoot进阶教程(二十九)整合Redis 发布订阅
SUBSCRIBE, UNSUBSCRIBE 和 PUBLISH 实现了 发布/订阅消息范例,发送者 (publishers) 不用编程就可以向特定的接受者发送消息 (subscribers). Ra ...
随机推荐
- ArcGIS Server 10 Java 版的Rest服务手动配置方法
Java版的Manager中发布的服务默认只发布了该服务的SOAP接口,而REST接口需要用户在信息服务器,如Tomcat. Apache.WebLogic等中手工配置.由于在Java版的Server ...
- PBX 评测二
//由于诸事繁多,结果评测一拖再拖. 博客园的优化还行啊,PBX220搜索, 第一页,第四个就是上一篇的评测文章. 配置没有什么说的(按照说明/还有这篇无线迷你IPPBX-PBX220). 以下是在公 ...
- 16位汇编 多文件 intel汇编 编译器masm5.0 调用子程序库即静态库的自定义函数 WINDOWS
;以下是16位汇编 创建静态库,并调用静态库中的函数 ;多文件汇编格式 ;编译方法(此处用的是masm 5.0,如果是其他的编译器,有可能不能编译) ;第一种,编译方法 ;1.masm main.as ...
- [转]LibreOffice-SDK 开发实战:嵌入MFC-View 和 C# Winform
转自:http://www.aqcoder.com/blog/detail/id/1579bb39-9bcd-4c0f-9b02-67a851148196/ 前面片文章中我简要介绍了下 LibreOf ...
- 【如何在mysql 官网下载最新版本mysql 数据库】
方法/步骤 打开百度搜索,输入MySQL,第一个是MySQL官网 点击第一个链接地址,进入MySQL官方网站,单击“Downloads”下载Tab页,进入下载界面 找到Community( ...
- 我与solr(二)--导入mysql数据库
关于solr的搭建详见上一篇的随笔. 步骤1: 在webapps中solrhome下新建一个文件夹名字叫做mynode(名字不固定,可以随便取,但是这个名字在后面的配置中会有所关联.)然后在mynod ...
- IE 浏览器 如何关闭令人讨厌的“此网站需要运行以下加载项:XXX。如果您信任该网站和该加载项并允许运行该加载项,请单击这里...
1.运行gpedit.msc 2.在打开的组策略中打开用户配置——管理模板——Windows组件——Internet Explorer 3.选择“关闭ActiveX选择启用提示”,将其状态改为“已启用 ...
- html 页面中显示单行省略号
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...
- C++函数返回局部指针变量
遇到过好几次关于函数返回指针变量问题,有时候是可以的,有时候是不可以的,然后就混乱了.今天研究了下,结果发现原来和内存分配有关. 用下面的例子分析下吧: char * test() { char a[ ...
- eclipse maven testng
安装过程: 1.eclipse官网下载: