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. php版本CKEditor 4和CKFinder安装及配置

    下载并解压CKEditor 4和CKFinder CKEditor 4下载地址:https://ckeditor.com/cke4/builder,选择自定义的版本,记得加上中文语言包 CKFinde ...

  2. 吴恩达-coursera-机器学习-week8

    十三.聚类(Clustering) 13.1 无监督学习:简介 13.2 K-均值算法 13.3 优化目标 13.4 随机初始化 13.5 选择聚类数 十四.降维(Dimensionality Red ...

  3. ELASTIC制图等高级使用

    基于上一个安装部署的文档后(ELASTIC 5.2部署并收集nginx日志) http://www.cnblogs.com/kerwinC/p/6387073.html 本次带来一些使用的分享. ki ...

  4. SVN提示https证书验证失败问题svn: E230001: Server SSL certificate verification failed:

    最近在使用Idea 检出 svn项目时,出现了如下的画面 显示需要授权证书,需要证书路径 搜索网上的解决方式:无非以下几种 1.File->Settings->Version Contro ...

  5. 使用CefSharp在.Net程序中嵌入Chrome浏览器(五)——Javascript交互

    要在CEF中和网页的JS进行交互,首先我们要通过设置启用Javascrit集成功能. CefSharpSettings.LegacyJavascriptBindingEnabled = true; 调 ...

  6. 用C扩展Python3

    官方文档: https://docs.python.org/3/extending/index.html 交叉编译到aarch64上面 以交叉编译到aarch64上面为例,下面是Extest.c的实现 ...

  7. Unity3D实践系列03,使用Visual Studio编写脚本与调试

    在Unity3D中,只有把脚本赋予Scene中的GameObject,脚本才会得以执行. 添加Camera类型的GameObject. Unity3D默认使用"MonoDevelop&quo ...

  8. (Delphi) Using the Disk Cache 使用磁盘缓存

    The Chilkat Spider component has disk caching capabilities. To setup a disk cache, create a new dire ...

  9. [转]过XX游戏驱动保护的代码

    这个是过TX游戏自我保护驱动的源代码.可以过qq堂.DNF.寻仙等QQ游戏. #include <ntddk.h>#include <windef.h>#include < ...

  10. mormot支持https

    mormot支持https 将ssl证书导入电脑系统,以Windows 10为例: 运行 mmc 证书导入成功后,双击证书,查看证书指纹: 第二项工作:将证书与https绑定:以管理员身份启动cmd, ...