SSH--------------easyui-datagrid的使用(1、列表初步使用)

1、在页面中获取

<%--
  Created by IntelliJ IDEA.
  User: Dong
  Date: 2020/4/27
  Time: 16:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/ztree3.5/zTreeStyle.css" type="text/css">
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/ztree3.5/jquery.ztree.all-3.5.js"></script>
</head>
<body>

<table class="easyui-datagrid">
    <thead>
    <tr>
        <th data-options="field:'itemid',width:80">编号</th>
        <th data-options="field:'productid',width:100">姓名</th>
        <th data-options="field:'listprice',width:80,align:'right'">手机号</th>

    </tr>
    </thead>
    <tr>
    <td>A01</td>
    <td>李三</td>
    <td>110</td>
</tr>
    <tr>
        <td>A01</td>
        <td>李三</td>
        <td>110</td>
    </tr>
</table>
</body>
</html>

 2、在JSON文件中获取

<%--
  Created by IntelliJ IDEA.
  User: Dong
  Date: 2020/4/27
  Time: 16:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/js/ztree3.5/zTreeStyle.css" type="text/css">
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/ztree3.5/jquery.ztree.all-3.5.js"></script>
</head>
<body>


<table class="easyui-datagrid" data-options="url:'${pageContext.request.contextPath}/demo/stafftest.json'">
    <thead>
    <tr>
        <th data-options="field:'id',width:80">编号</th>
        <th data-options="field:'name',width:100">姓名</th>
        <th data-options="field:'age',width:80,align:'right'">手机号</th>

    </tr>
    </thead>

</table>
</body>
</html>
stafftest.json:
[
  {"id":"001","name":"李大","age":"13912345678","haspda":"1","deltag":"0","standard":"10-20公斤","station":"杭州分部"},
  {"id":"002","name":"李二","age":"13912345678","haspda":"1","deltag":"0","standard":"10-20公斤","station":"杭州分部"},
  {"id":"003","name":"李二","age":"13912345678","haspda":"1","deltag":"0","standard":"10-20公斤","station":"杭州分部"},
  {"id":"004","name":"李二","age":"13912345678","haspda":"1","deltag":"0","standard":"10-20公斤","station":"杭州分部"}
]

 

3、通过JS动态创建datagrid

  1. 代码:

<script type="text/javascript">

    $(function () {

       $('#grid').datagrid({   

           url:'/Bos/json/stafftest.json',   

           columns:[[   

               {field:'id',title:'编号',width:100,checkbox:true},   

               {field:'name',title:'名字',width:100},   

               {field:'age',title:'手机',width:100,align:'right'}   

           ]],

           toolbar: [{

              iconCls: 'icon-edit',

              text:'Edit',

              handler: function(){alert('编辑按钮')}

           },'-',{

              iconCls: 'icon-help',

              text:'Help',

              handler: function(){alert('帮助按钮')}

           },'-',{

              text:'删除',

              handler: function(){}

           },'-',{

              text:'修改',

              handler: function(){}

           }]

 

       });

    });

</script>

js的方式渲染datagrid

<table id="grid"></table>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值