关于EasyUIDataGrid查询功能

 1 <table id="studentInfo" data-options="toolbar:'#ft'" ></table>
 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 });

一个查询:

<div id="ft" style="padding:2px 5px;">
    学号:<input id="Id" name="Id" class="textbox" type="text" />
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"></a>
    姓名:<input id="Name" name="Name" class="textbox" type="text" />
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"></a><br />
    性别:<input id="Sex" name="Sex" class="textbox" type="text" />
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"></a>
    年龄:<input id="Age" name="Age" class="textbox" type="text" />
    <a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" οnclick="obj.search()"></a>
</div>

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值