EasyUI之datagrid学习Demo

1.引入必要文件

<script type="text/javascript" src="js/EasyUI/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/EasyUI/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/EasyUI/js/easyui-lang-zh_CN.js"></script>

       <link rel="stylesheet" type="text/css" href="EasyUI/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="EasyUI/themes/icon.css">
<link rel="stylesheet" type="text/css" href="EasyUI/demo.css">

2.编写展示页面并配置

<div id="customer" class="easyui-window" title="客户信息" data-options="modal:true,closed:true,iconCls:'icon-tip',top:100" style="width:730px;height:400px;padding:10px;">
    <table id="dg" class="easyui-datagrid" title="客户信息列表" style="width:700px;height:300px" data-options="
rownumbers:false,
singleSelect:true,
autoRowHeight:false,
pagination:true,
pageSize:10">
<thead>
<tr>
    <th field="id" width="80">客户ID</th>
<th field="name" width="80">客户名称</th>
<th field="address" width="100">客户地址</th>
<!--<th field="name" width="80">客户类型</th>
<th field="amount" width="80" align="right">客户级别</th>
<th field="price" width="80" align="right">客户地址</th>
--></tr>
</thead>
</table>
 </div>

3.编写js

function showCustomers(){
         $("#dg").datagrid({
         url:'AjaxCustomerInfoAction_AjaxShowCostomerInfo.action',//数据源
         loadFilter: function(data){

                                 //自定义数据过滤器,返回的data必须包含   "total"和"rows"

                                //该过滤器可以将自定义数据转换为标准的data数据

                               //data.totalCount和data.customerinfolist获取的是自定义的数据
        if (data.totalCount&&data.customerinfolist){
            var mydata={
                                            "total":data.totalCount,
                                           "rows":data.customerinfolist                                                        
                                          }
            return mydata;
        } else {
        return data;
        
        },

                            //单击某一列时触发的事件
         onClickRow:function(rowIndex, rowData){
                               $('#ff').form('load',{
                                customerId:rowData.id,
                               customerInfoName:rowData.name
          });
                             $('#customer').window('close');
                },
         pageSize:5,//此处的数值必须是pageList中的数值
         pageList:[5,10,15,20,25,30]
         });
          $('#customer').window('open');
         }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值