easyui--5.DataGrid

1      Html方式(了解)

 <!--html形式实现
<table class="easyui-datagrid">   
    <thead>   
        <tr>   
            <thdata-options="field:'code'">编码</th>   
            <thdata-options="field:'name'">名称</th>   
            <thdata-options="field:'price'">价格</th>   
        </tr>   
    </thead>   
    <tbody>   
        <tr>   
           <td>001</td><td>name1</td><td>2323</td>   
        </tr>   
        <tr>   
           <td>002</td><td>name2</td><td>4612</td>   
        </tr>   
    </tbody>   
</table>  
-->

 

2      Html+js

2.1  Html

<table id="dg"></table> 

2.2  Js

$('#dg').datagrid({
    url:'datagrid_data.json',
    columns:[[
        {field:'stuNum',title:'学号',width:100},
        {field:'stuName',title:'姓名',width:100},
        {field:'stuSex',title:'性别',width:100,},
      {field:'stuAge',title:'年龄',width:100,},
      {field:'stuQQ',title:'QQ',width:100,},
    ]],
   pagination:true
});

3      混合方式(推荐)

3.1  Html

<table id="dg" class="easyui-datagrid" style="width:700px;height:350px"   
      data-options="fitColumns:true,singleSelect:true,pagination:true,toolbar:'#tb'">   
  <thead>   
      <tr>   
          <th data-options="field:'stuNum',width:100">学号</th>   
          <th data-options="field:'stuName',width:100">姓名</th> 
          <th data-options="field:'stuSex',width:100">性别</th>
   <th data-options="field:'stuAge',width:100">年龄</th>
   <th data-options="field:'stuQQ',width:100">QQ</th>   
      </tr>   
  </thead>   
 </table>

 <div id="tb">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'"> 新建</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit'"> 编辑</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"> 删除</a>
 </div> 

3.2  Js

$('#dg').datagrid({
      url:'datagrid_data.json'
});    

 

4      实例

4.1  返回结果pojo

/**
 * 用于接受easyUI 分页表格数据,也可以用map代替
 */
public class EasyUIDataGridResult implements Serializable{
    private Long total;

    private List<?> rows;

    public LonggetTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<?>getRows() {
        return rows;
    }

    public void setRows(List<?> rows) {
        this.rows = rows;
    }
} 

1.2  Controller接受参数

 

1.3  Service

public EasyUIDataGridResult getItemList(int page, int rows) {
    //1.设置分页信息
    PageHelper.startPage(page,rows);
    //2.执行查询
    List<TbItem> itemList = itemMapper.selectByExample(new TbItemExample());
    //3.取分页结果 Rows:itemList , Total
    PageInfo<TbItem> pageInfo = new PageInfo<>(itemList);
    long total= pageInfo.getTotal();

    //4.返回值对象
    EasyUIDataGridResult result = new EasyUIDataGridResult();
    result.setRows(itemList);       //分页结果
    result.setTotal(total);
    return result;
}

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值