html代码:

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Index_Layout.cshtml";
} <!DOCTYPE html> <html>
<head>
<meta name="viewport" content="width=device-width" />
<title>GridView</title> <script type="text/javascript">
$(function () {
$('#List').datagrid({
toolbar: [{
text: '添加',
iconCls: 'icon-add',
height:50,
handler: function () {
$('#List').datagrid('endEdit', lastIndex);
lastIndex = $('#List').datagrid('getRows').length - 1;
$('#List').datagrid('selectRow', lastIndex);
$('#List').datagrid('beginEdit', lastIndex);
}
}, '-', {
text: '删除',
iconCls: 'icon-remove',
height: 50,
handler: function () {
var row = $('#List').datagrid('getSelected');
if (row) {
var index = $('#List').datagrid('getRowIndex', row);
$('#List').datagrid('deleteRow', index);
}
}
}, '-', {
text: '保存',
iconCls: 'icon-save',
height: 50,
handler: function () {
$('#List').datagrid('acceptChanges');
}
}, '-', {
text: '刷新',
height: 50,
iconCls: 'icon-undo',
handler: function () {
$('#List').datagrid('rejectChanges');
}
}, '-', {
text: '搜索',
height: 50,
iconCls: 'icon-search',
handler: function () {
var rows = $('#List').datagrid('getChanges');
alert('changed rows: ' + rows.length + ' lines');
}
}],
title:"DataGrid的标题",
url: '/AjaxUser/loadjson2',
width: 500,
methord: 'post',
height:500,
fitColumns: true,
sortName: 'id',
sortOrder: 'desc',
idField: 'id',
pageSize: 20,
//pageList: 20,
pagination: true,
striped: true, //奇偶行是否区分
singleSelect: true,//单选模式
rownumbers: true,//行号
columns: [[
{ field: 'id', title: 'id', width: 80 },
{ field: 'realname', title: '名称', width: 120 },
{ field: 'sex', title: 'sex', width: 80, align: 'left' }
]]
});
});
</script> </head>
<body>
<div>
<table id="List"></table>
</div>
</body>
</html>

  

@{
Layout = null;
} <!DOCTYPE html>
<html>
<head>
<title>Main</title> <script src="@Url.Content("~/Scripts/jquery.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
@Styles.Render("~/Content/themes/gray/easyui.css")
@Styles.Render("~/Content/themes/icon.css")
</head>
<body>
<div style="padding:5px 5px 0px 5px;">
@RenderBody()
</div>
</body>
</html>

  

控制器

    public ActionResult loadjson2(int page=1, int rows=20, string sort="id", string order="desc")
{
List<tbl_admin> list = shop.tbl_admin.OrderBy(u => sort)
.Skip(rows * (page-1))
.Take(rows)
.ToList();
var json = new
{
total = shop.tbl_admin.Count(),
rows = (from r in list
select new tbl_admin()
{
id = r.id,
realname = r.realname,
sex = r.sex
}).ToArray()
};
return Json(json, JsonRequestBehavior.AllowGet);
} public ActionResult GridView()
{
return View();
}

  

easyUi 的DataGrid的绑定的更多相关文章

  1. EasyUI 中 DataGrid 控件 列 如何绑定对象中的属性

    EasyUI 中 DataGrid 控件 是我们经常用到的控件之一, 但是 DataGrid 控件 在绑定显示列时却不支持对象属性绑定. 模型如下: public class Manager impl ...

  2. EasyUI中, datagrid用loadData方法绑定数据。

    $("#dg").datagrid("loadData", { , " }, { "ck": "1", &qu ...

  3. easyui的datagrid分页写法小结

    easyui的datagrid分页死活不起作用...沙雕了...不说了上代码 //关闭tab1打开tab2 查询Detail function refundDetail(){ $('#tt').tab ...

  4. 在EasyUI的DataGrid中嵌入Combobox

    在做项目时,须要在EasyUI的DataGrid中嵌入Combobox,花了好几天功夫,在大家的帮助下,最终看到了它的庐山真面: 核心代码例如以下: <html> <head> ...

  5. easyui+struts2:datagrid无法不能得到数据

    转自:https://bbs.csdn.net/topics/390980437 easyui+struts2:datagrid无法访问到指定action: userlist.jsp部分代码: XML ...

  6. easyUI 中datagrid 返回列隐藏方法

    easyui的datagrid方法返回的列,有的值不需要显示可以使用hidden(属性进行隐藏) columns : [ [{ field : 'bailClass', title : '类别', w ...

  7. easyui的datagrid行的某一列添加链接

    通过formatter方法给easyui 的datagrid 每行增加操作链接. 效果图 jsp代码: <th field="url" width="100&quo ...

  8. easyui的datagrid打印(转)

    在使用easyui插件的时候,使用最多的应该是datagrid插件.有时候根据客户需求,可能需要将datagrid内容进行打印,这时候如果直接调用window.print,可能由于easyui的dat ...

  9. EasyUI的datagrid分页

    EasyUI的datagrid分页 前台代码: <script type="text/javascript"> $(function () { //查询 search( ...

随机推荐

  1. kafka 基础知识梳理

    一.kafka 简介 kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据.这种动作(网页浏览,搜索和其他用户的行动)是在现代网络上的许多社会功能的一个关键因 ...

  2. 013.Zabbix的Items(监控项)

    一 Items简介 Items是从主机里面获取的所有数据,可以配置获取监控数据的方式.取值的数据类型.获取数值的间隔.历史数据保存时间.趋势数据保存时间.监控key的分组等. 通常情况下item由ke ...

  3. 【GO基础】main redeclared in this block问题的排查与解决

    之前的GO练习环境放在虚拟机内,方便了不少.不过在liteIDE打开的情况下,我迁移了虚拟机,刚好两台机子的VMware版本还不同,这就导致了无法恢复挂起状态,我放弃了挂起. 重新启动后,为了继续练习 ...

  4. JDK1.8快速入门

    JDK8提供了非常多的便捷用法和语法糖,其编码效率几乎接近于C#开发,maven则是java目前为止最赞的jar包管理和build工具,这两部分内容都不算多,就合并到一起了. 愿编写java代码的过程 ...

  5. rabbitmq学习(四) —— 发布订阅

    为了说明这种模式,我们将建立一个简单的日志系统.这个系统将由两个程序组成,第一个将发出日志消息,第二个将接收并处理日志消息.在我们的日志系统中,每一个运行的接收程序的副本都会收到日志消息. 交换器(E ...

  6. php7 & lua 压测对比

    内存:32G CPU:2个6核 接口数据deflate 压缩后 均不到10k, ==== php7 ==== Concurrency Level: 100 Time taken for tests: ...

  7. [JZOJ4786]小a的强迫症

    [JZOJ4786]小a的强迫症 题目大意: 有\(n(n\le10^5)\)种颜色的珠子,第\(i\)种颜色有\(num[i]\)个.你要把这些珠子排成一排,使得第\(i\)种颜色的最后一个珠子一定 ...

  8. Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力

    B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...

  9. Springboot 线程池配置

    最近的项目里要手动维护线程池,然后看到一起开发的小伙伴直接用Java了,我坚信Springboot不可能没这功能,于是查了些资料,果然有,这里给一下. 首先我们都知道@Async标签能让方法异步执行, ...

  10. slf4j 和 log4j合用的(Maven)配置

    简述: 添加logger的日志输出,下面是配置信息供备忘   步骤: 1. 在Maven的porn.xml 文件中添加dependency如下 <dependency> <group ...