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. net mvc cms

    .NET作品集:linux下的.net mvc cms   cms程序架构 本程序是主要是用于企业网站开发的,也可以做博客程序,程序是从之前上一篇的.net 博客程序改进过来的,主要技术由webfor ...

  2. maven中的各种问题

    [ERROR] Plugin org.apache.maven.plugins:maven-shade-plugin:3.1 or one of its dependencies could not ...

  3. elasticsearch query dsl

    1.match / match_phrase / match_phrase_prefix / multi_match[查询] 1.1 match 它会根据所给的字符串,进行分词,然后去找出,包含这些分 ...

  4. vue-video-player的使用总结

    由于公司的项目是网上教育的,像网易云课堂那种教育网站,因而会有很多课程需要在线观看的,所以视频插件是必不可少的. 由于我用vue开发项目,所以找视频插件也找和vue贴近的.最后选择了vue-video ...

  5. linux 驱动之LCD驱动(有framebuffer)

    <简介> LCD驱动里有个很重要的概念叫帧缓冲(framebuffer),它是Linux系统为显示设备提供的一个接口,应用程序在图形模式允许对显示缓冲区进行读写操作.用户根本不用关心物理显 ...

  6. android 手机不能断点

    一个安卓平板 型号 联想 .. ,用andriod studio 打断点 调试, 应用 就卡死2秒,然后就挂掉了.  不知如何解决.

  7. Markdown基础用法

    1. 标题 文字前加#,共6级标题,# 一级标题,## 二级标题,...,###### 六级标题 2. 列表 文字前加-或* 即可变无序列表,文字前加 数字. 即可变有序列表 3. 引用 在引用文本前 ...

  8. Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip dfs 按位考虑

    E. Mahmoud and a xor trip 题目连接: http://codeforces.com/contest/766/problem/E Description Mahmoud and ...

  9. Xtreme8.0 - Kabloom dp

    Xtreme8.0 - Kabloom 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/kablo ...

  10. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) D. Dense Subsequence 暴力

    D. Dense Subsequence 题目连接: http://codeforces.com/contest/724/problem/D Description You are given a s ...