关于EasyUIDataGrid查询功能

 1 "studentInfo" data-options="toolbar:'#ft'" >
2 3 $(function () { 4 $('#studentInfo').datagrid({ 5 url: '/Default/getJson', 6 dataType: 'json', 7 title: '学生信息', 8 width: 700, 9 idField: 'id', 10 queryParams:{ 11 id: "", 12 name: "", 13 sex: "", 14 age: "" 15 }, 16 height: 400, 17 loadMsg: '正在加载...', 18 striped: true, 19 columns: [[ 20 { field: 'id', title: '学号' }, 21 { field: 'name', title: '姓名' }, 22 { field: 'sex', title: '性别' }, 23 { field: 'age', title: '年龄' }, 24 { field: 'dept', title: '..' } 25 ]], 26 singleSelect: false, 27 rownumbers: true, 28 pagination: true, 29 pageList: [10, 15, 20] 30 }); 31 var p = $('#studentInfo').datagrid('getPager'); 32 $(p).pagination({ 33 beforePageText: '', 34 afterPageText: '页 共{pages}页', 35 displayMsg: '当前显示{from}-{to}条记录 共{total}条记录' 36 }); 37 });

一个查询:

"ft" style="padding:2px 5px;"> 学号:"Id" name="Id" class="textbox" type="text" /> "#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"> 姓名:"Name" name="Name" class="textbox" type="text" /> "#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()">
性别:"Sex" name="Sex" class="textbox" type="text" /> "#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"> 年龄:"Age" name="Age" class="textbox" type="text" /> "#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()">
var obj = { search: function () { $('#studentInfo').datagrid('load', { id: $('#Id').val().trim(), name: $('#Name').val().trim(), sex: $('#Sex').val().trim(), age: $('#Age').val().trim() }); } };

控制器:

public JsonResult getJson(int page, int rows, string age, string sex, string name, string id)
        {
            var st=db.student.Where(s=>s.id.Contains(id)&&s.name.Contains(name)&&s.sex.Contains(sex)&&SqlFunctions.StringConvert((double)s.age).Contains(age)).ToList();
            return Json(new { total = st.Count, rows = st.Skip((page - 1) * rows).Take(rows) });
        }

 

转载于:https://www.cnblogs.com/CymbidiumSky/p/4537693.html

你可能感兴趣的:(关于EasyUIDataGrid查询功能)