• EasyUI入门,DataGrid(数据表格)


    搭建EasyUI

    1.进入官网,下载EasyUI的程序包。地址:http://www.jeasyui.com/download/list.php

    2.先导入css样式,引入程序包

    3.进入EasyUI程序入门

     <1>第一次发现分页是如此简便

    js代码

     $(function () {

                $('#dg').datagrid({
                    url: '/Main/FenYe1',
                    loadMsg: '请稍等,正在拼命加载...',
                    fitColumns: false,//防止水平滚动
                    rownumbers: true, //是否加行号
                    pagination: true, //是否显式分页
                    pageSize: 5, //页容量,必须和pageList对应起来,否则会报错
                    pageNumber: 1, //默认显示第几页
                    pageList: [5, 10, 15],//分页中下拉选项的数值
                    checkOnSelect: true,
                    selectOnCheck: true,
                    //striped:true,//显示斑马线效果。
                    frozenColumns: [[
                        {
                            field: 'id', title: '请选择..', 58, align: 'center',
                            checkbox: true
                        },
                        { field: 'name', title: '名称', 100 },
                    ]],
                    columns: [[
                       
                       
                        { field: 'sex', title: '性别', 100 },
                        { field: 'age', title: '年龄', 100 },
                        { field: 'dataTime', title: '记录时间', 150, align: 'center' },
                        { field: 'content', title: '个人介绍', 250, align: 'left' },

                    ]],
                });


                //导航栏
                $('#dg').datagrid({
                    toolbar: [
                    { text: '增加', iconCls: 'icon-add', handler: function () { addStu(); } }, '-',
                    { text: '修改', iconCls: 'icon-edit', handler: function () { edittbUser(); } }, '-',
                    { text: '删除', iconCls: 'icon-remove', handler: function () { deleteUser(); } }, '-',
                    { text: '查看', handler: function () { } }, '-',
                    { text: '刷新', iconCls: 'icon-reload', handler: function () { deviceInfoRefreshClick(); } }, '-',
                    { text: '导出', iconCls: 'icon-save', handler: function () { $(dg).treegrid('reload'); } }, '-'],
                });


            });

     Controller:

      public ActionResult FenYe1(int rows, int page)
            {
                try
                {
                    var Stu_List = db.Set<student>().OrderByDescending(a => a.dataTime).Skip(rows * (page - 1)).Take(rows).ToList();
                    var json = new
                    {
                        total = db.Set<student>().Count(),
                        rows = (from r in Stu_List
                                select new
                                {
                                    id = r.id,
                                    name = r.name,
                                    sex = r.sex,
                                    age = r.age,
                                    dataTime = r.dataTime.ToString(),
                                    content = r.content,

                                }).ToList(),

                    };

                    return Json(json);
                }
                catch (Exception ex)
                {
                    FileOperateHelp.WriteFile("E:/ErrorLog333.txt", ex.Message);
                    return Content("error");
                }
            }

    作者:chenze
    出处:https://www.cnblogs.com/chenze-Index/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    如果文中有什么错误,欢迎指出。以免更多的人被误导。
  • 相关阅读:
    First Missing Positive
    Find Minimum in Rotated Sorted Array II
    switch两种写法对比
    常用的前端JavaScript方法封装
    如何保证缓存和数据库的一致性?
    14个前端小知识
    dataTable转换特定的类
    C# MD5 32大写位加密 UTF-8编码
    另一个 SqlParameterCollection 中已包含 SqlParameter
    C#实现数据回滚,A事件和B事件同时执行,其中任何一个事件执行失败,都会返回失败
  • 原文地址:https://www.cnblogs.com/chenze-Index/p/9209652.html
Copyright © 2020-2023  润新知